/* ================================================================
   Hifz Companion — Design System
   Quran Memorization System — Modern Islamic UI
   v2.0 · Bootstrap 5.3 RTL overlay
   ================================================================ */

/* ────────────────────────────────────────
   1. Design Tokens
──────────────────────────────────────── */
:root {
    /* — Emerald (primary) */
    --em-700: #0F766E;
    --em-600: #0D9488;
    --em-500: #10B981;
    --em-400: #34D399;
    --em-100: #D1FAE5;
    --em-50:  #ECFDF5;

    /* — Purple (secondary / revision) */
    --pu-700: #6D28D9;
    --pu-600: #7C3AED;
    --pu-500: #8B5CF6;
    --pu-100: #EDE9FE;
    --pu-50:  #F5F3FF;

    /* — Gold (achievements / streaks) */
    --go-600: #B45309;
    --go-500: #D97706;
    --go-400: #F59E0B;
    --go-300: #FCD34D;
    --go-100: #FEF3C7;
    --go-50:  #FFFBEB;

    /* — Ink (typography) */
    --ink-900: #0B132B;
    --ink-800: #1E293B;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #64748B;
    --ink-400: #94A3B8;
    --ink-300: #CBD5E1;
    --ink-200: #E2E8F0;
    --ink-100: #F1F5F9;

    /* — Semantic */
    --c-danger:  #E11D48;
    --c-danger-bg: #FFF1F2;
    --c-info:    #0EA5E9;
    --c-info-bg: #F0F9FF;
    --c-success: var(--em-500);

    /* — Surfaces */
    --c-bg:      #F8FAFC;
    --c-surface: #FFFFFF;
    --c-border:  var(--ink-200);

    /* — Layout */
    --sidebar-w: 268px;
    --topbar-h:  64px;

    /* — Shadows */
    --sh-xs: 0 1px 2px rgba(15,23,42,.06);
    --sh-sm: 0 2px 8px  rgba(15,23,42,.06);
    --sh-md: 0 4px 16px rgba(15,23,42,.08);
    --sh-lg: 0 12px 40px rgba(15,23,42,.10);
    --sh-em: 0 6px 20px rgba(15,118,110,.20);

    /* — Radii */
    --r-sm:  8px;
    --r-md:  12px;
    --r-lg:  16px;
    --r-xl:  24px;
    --r-2xl: 32px;
    --r-pill: 999px;

    /* — Gradient presets */
    --grad-emerald:  linear-gradient(135deg, var(--em-700) 0%, var(--em-500) 100%);
    --grad-spiritual: linear-gradient(135deg, var(--em-700) 0%, var(--pu-600) 100%);
    --grad-gold:     linear-gradient(135deg, var(--go-600) 0%, var(--go-400) 100%);
    --grad-sidebar:  linear-gradient(180deg, #0a2420 0%, #0e2f2a 60%, #0d1f1d 100%);

    /* — Transitions */
    --t-fast: 120ms ease;
    --t-std:  200ms ease;
    --t-slow: 350ms ease;
}

.table thead th,
table.dataTable thead th,
table.dataTable thead td {
    text-align: right !important;
}

.table tbody td,
.table tbody th,
table.dataTable tbody td,
table.dataTable tbody th,
table.h-table thead th,
table.h-table tbody td,
table.h-table tbody th {
    text-align: right !important;
}

/* ────────────────────────────────────────
   2. Reset & Base
──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Tajawal', 'Cairo', 'Segoe UI', system-ui, sans-serif;
    background: var(--c-bg);
    color: var(--ink-800);
    line-height: 1.65;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

body.branch-panel {
    --br-800: #3f2412;
    --br-700: #7c2d12;
    --br-600: #9a3412;
    --br-500: #c05621;
    --br-100: #ffedd5;
    --br-50: #fff7ed;
    --cy-700: #0e7490;
    --cy-500: #06b6d4;
    --grad-branch-sidebar: linear-gradient(180deg, #2a170b 0%, #3f2412 45%, #123640 100%);
    --grad-branch: linear-gradient(135deg, #7c2d12 0%, #0e7490 100%);
    --c-success: var(--br-500);
}

.font-quran {
    font-family: 'Amiri Quran', 'Amiri', serif;
    line-height: 2.4;
}

/* ────────────────────────────────────────
   3. Auth Layout
──────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: var(--grad-spiritual);
    padding: 2.5rem 1rem;
    position: relative;
    overflow-x: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 15% 20%, rgba(255,255,255,.08) 0, transparent 50%),
        radial-gradient(ellipse at 85% 80%, rgba(212,160,23,.12) 0, transparent 50%);
    pointer-events: none;
}

.auth-page-jamia {
    background:
        linear-gradient(135deg, #0f766e 0%, #0b4f6c 48%, #164e63 100%);
}

.auth-page-jamia::before {
    background:
        radial-gradient(ellipse at 18% 18%, rgba(255,255,255,.10) 0, transparent 48%),
        radial-gradient(ellipse at 82% 78%, rgba(56,189,248,.16) 0, transparent 52%),
        linear-gradient(180deg, rgba(15,118,110,.08) 0, rgba(8,47,73,.22) 100%);
}

.auth-page-admin {
    background:
        linear-gradient(180deg, #1e1035 0%, #2d1b69 60%, #1a0f3c 100%);
}

.auth-page-admin::before {
    background:
        radial-gradient(ellipse at 14% 18%, rgba(255,255,255,.08) 0, transparent 46%),
        radial-gradient(ellipse at 84% 76%, rgba(139,92,246,.20) 0, transparent 52%),
        linear-gradient(180deg, rgba(76,29,149,.10) 0, rgba(30,16,53,.24) 100%);
}

.auth-page .auth-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 460px;
    background: var(--c-surface);
    border-radius: var(--r-2xl);
    box-shadow: var(--sh-lg);
    overflow: hidden;
    /* keep vertical margin when content is centered */
    margin: auto;
}
.auth-page .auth-card--wide {
    max-width: 920px;
}

.auth-card-header {
    background: linear-gradient(135deg, var(--c-surface) 0%, var(--em-50) 100%);
    padding: 2.5rem 2rem 1.75rem;
    text-align: center;
    border-bottom: 1px solid var(--c-border);
}

.auth-brand-icon {
    width: 80px; height: 80px;
    margin: 0 auto 1rem;
    background: var(--grad-emerald);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem;
    color: #fff;
    box-shadow: var(--sh-em);
    border: 4px solid #fff;
}

.auth-card-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--em-700);
    margin: 0 0 .5rem;
}

.auth-card-verse {
    font-family: 'Amiri', serif;
    font-size: 1rem;
    color: var(--go-600);
    margin: 0;
}

.auth-card-body { padding: 2rem; }

.auth-card-footer {
    padding: .9rem;
    background: var(--ink-100);
    text-align: center;
    color: var(--ink-500);
    font-size: .8rem;
    border-top: 1px solid var(--c-border);
}

/* ────────────────────────────────────────
   4. App Shell (Sidebar + Topbar + Main)
──────────────────────────────────────── */
.hifz-wrapper { display: flex; min-height: 100vh; background: var(--c-bg); }

/* ── Sidebar ── */
.hifz-sidebar {
    width: var(--sidebar-w);
    background: var(--grad-sidebar);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: width var(--t-std);
    box-shadow: -3px 0 24px rgba(0,0,0,.18);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.12) transparent;
}

.branch-panel .hifz-sidebar {
    background: var(--grad-branch-sidebar);
}

.branch-panel .sidebar-brand-icon,
.branch-panel .auth-brand-icon {
    background: var(--grad-branch);
    box-shadow: 0 6px 20px rgba(124,45,18,.22);
}

.branch-panel .sidebar-link.active {
    background: rgba(255,237,213,.14);
    color: #fff;
    border-color: rgba(255,237,213,.28);
}

.branch-panel .sidebar-link.active .sl-icon,
.branch-panel .sidebar-link:hover .sl-icon {
    color: #fed7aa;
}

.branch-panel .topbar-breadcrumb,
.branch-panel .page-title,
.branch-panel .h-card-header-title {
    color: var(--br-700);
}

.branch-panel .btn-primary,
.branch-panel .btn-h-primary {
    background: var(--br-700);
    border-color: var(--br-700);
}

.branch-panel .btn-primary:hover,
.branch-panel .btn-h-primary:hover {
    background: var(--br-600);
    border-color: var(--br-600);
}

.branch-hero {
    background: var(--grad-branch);
}

.branch-stat-link {
    display: block;
    color: inherit;
    text-decoration: none;
    height: 100%;
}

.branch-stat {
    border-color: rgba(124,45,18,.12);
}

.branch-stat .stat-icon {
    background: var(--br-50);
    color: var(--br-700);
}

.branch-stat-link:hover .branch-stat {
    border-color: rgba(14,116,144,.28);
    box-shadow: 0 10px 28px rgba(15,23,42,.09);
    transform: translateY(-1px);
}

/* subtle Islamic geometric pattern overlay */
.hifz-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M30 0l30 30-30 30L0 30z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

/* — Sidebar Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1.25rem 1rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    position: relative;
    z-index: 1;
}

.sidebar-brand-icon {
    width: 44px; height: 44px;
    background: var(--grad-emerald);
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    box-shadow: var(--sh-em);
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    line-height: 1.3;
}

.sidebar-brand-sub {
    font-size: .72rem;
    color: rgba(255,255,255,.5);
    display: block;
}

/* — Sidebar Nav */
.sidebar-nav {
    flex: 1;
    padding: .75rem .65rem;
    position: relative;
    z-index: 1;
}

.nav-group-label {
    padding: 1rem .7rem .4rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .65rem .8rem;
    border-radius: var(--r-sm);
    color: rgba(255,255,255,.72);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: .15rem;
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
    position: relative;
}

.sidebar-link:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.sidebar-link.active {
    background: var(--grad-emerald);
    color: #fff;
    box-shadow: var(--sh-em);
}

.sidebar-link .sl-icon {
    width: 22px;
    text-align: center;
    font-size: .95rem;
    flex-shrink: 0;
}

.sidebar-link .sl-badge {
    margin-right: auto;
    background: rgba(255,255,255,.15);
    color: #fff;
    font-size: .68rem;
    padding: .1rem .45rem;
    border-radius: var(--r-pill);
    font-weight: 700;
}

.sidebar-link.active .sl-badge {
    background: rgba(255,255,255,.25);
}

/* — Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.07);
    text-align: center;
    font-family: 'Amiri', serif;
    font-size: .95rem;
    color: var(--go-300);
    position: relative;
    z-index: 1;
}

/* ── Topbar ── */
.hifz-topbar {
    height: var(--topbar-h);
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--sh-xs);
}

.topbar-breadcrumb {
    flex: 1;
    font-size: .92rem;
    font-weight: 600;
    color: var(--ink-700);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar-icon-btn {
    width: 38px; height: 38px;
    border-radius: var(--r-md);
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--ink-600);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
    text-decoration: none;
    font-size: .9rem;
    position: relative;
}
.topbar-icon-btn:hover { background: var(--em-50); color: var(--em-700); }

.notif-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--c-danger);
    border: 2px solid #fff;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem .75rem .35rem .5rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    cursor: pointer;
    transition: background var(--t-fast);
    text-decoration: none;
}
.topbar-user:hover { background: var(--em-50); }

/* Evaluation workspace */
.evaluation-advance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--c-info-bg);
    border: 1px solid #bae6fd;
    border-right: 4px solid var(--c-info);
    border-radius: var(--r-sm);
}

.evaluation-track {
    --track-accent: var(--em-500);
    border-right: 4px solid var(--track-accent);
}

.evaluation-track-stabilization { --track-accent: var(--pu-600); }
.evaluation-track-review { --track-accent: var(--c-info); }
.evaluation-track-recitation { --track-accent: var(--go-500); }
.evaluation-track:hover { background: color-mix(in srgb, var(--track-accent) 5%, white); }

.number-stepper {
    display: grid;
    grid-template-columns: 2.25rem minmax(4rem, 1fr) 2.25rem;
    align-items: stretch;
    min-width: 8.5rem;
}

.number-stepper .stepper-input {
    min-width: 0;
    text-align: center;
    border-radius: 0;
    border-inline: 0;
    padding-inline: .25rem;
}

.stepper-button {
    border: 1px solid var(--c-border);
    background: var(--ink-100);
    color: var(--ink-700);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}

.stepper-button:first-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.stepper-button:last-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.stepper-button:hover { background: var(--em-50); color: var(--em-700); }

.evaluation-question {
    height: 100%;
    padding: 1rem;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: var(--ink-100);
}

.evaluation-test .table { border: 1px solid var(--c-border); }

.luhn-register tbody tr { border-right: 3px solid transparent; }
.luhn-register tbody tr:hover {
    border-right-color: var(--c-danger);
    background: var(--c-danger-bg);
}

.luhn-register td { padding-block: .9rem; }

.error-row {
    margin: 0 0 .75rem;
    padding: .9rem;
    border: 1px solid var(--c-border);
    border-right: 4px solid var(--c-danger);
    border-radius: var(--r-sm);
    background: var(--c-danger-bg);
}

@media (max-width: 767.98px) {
    .evaluation-advance { align-items: flex-start; flex-direction: column; }
    .number-stepper { min-width: 10rem; }
}

.topbar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--grad-emerald);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .82rem;
    flex-shrink: 0;
}

.topbar-user-name {
    font-size: .88rem;
    font-weight: 600;
    color: var(--ink-800);
}

/* ── Main Area ── */
.hifz-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

.hifz-content {
    flex: 1;
    padding: 1.75rem;
}

.hifz-footer {
    padding: .9rem 1.5rem;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    text-align: center;
    color: var(--ink-400);
    font-size: .8rem;
}

/* ────────────────────────────────────────
   5. Page Header
──────────────────────────────────────── */
.page-hdr {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-hdr-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ink-900);
    margin: 0 0 .2rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.page-hdr-title .title-icon {
    width: 36px; height: 36px;
    background: var(--em-50);
    color: var(--em-700);
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem;
}

.page-hdr-sub { font-size: .88rem; color: var(--ink-500); margin: 0; }

/* ────────────────────────────────────────
   6. Flash Alerts
──────────────────────────────────────── */
.hifz-alert {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.1rem;
    border-radius: var(--r-md);
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
    animation: slideInDown .25s ease;
}
.hifz-alert-success { background: var(--em-50); color: var(--em-700); border-color: var(--em-100); }
.hifz-alert-error   { background: var(--c-danger-bg); color: var(--c-danger); border-color: #fecdd3; }
.hifz-alert-info    { background: var(--c-info-bg); color: var(--c-info); border-color: #bae6fd; }
.hifz-alert .alert-close {
    margin-right: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: .85rem;
    opacity: .6;
    padding: 0;
    line-height: 1;
}
.hifz-alert .alert-close:hover { opacity: 1; }

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

/* ────────────────────────────────────────
   7. Cards
──────────────────────────────────────── */
.h-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    overflow: hidden;
    transition: box-shadow var(--t-std), transform var(--t-std);
}
.h-card:hover { box-shadow: var(--sh-md); }

.h-card-body  { padding: 1.5rem; }
.h-card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.h-card-header-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--ink-800);
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0;
}
.h-card-header-title .card-icon {
    width: 28px; height: 28px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: .78rem;
}
.h-card-footer {
    padding: .85rem 1.5rem;
    border-top: 1px solid var(--c-border);
    background: var(--ink-100);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* — Stat Card */
.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 1.35rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--sh-sm);
    transition: transform var(--t-std), box-shadow var(--t-std);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-bar, var(--em-500));
    border-radius: 0 var(--r-lg) var(--r-lg) 0;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.stat-card.tone-emerald { --accent-bar: var(--em-500); }
.stat-card.tone-purple  { --accent-bar: var(--pu-500); }
.stat-card.tone-gold    { --accent-bar: var(--go-400); }
.stat-card.tone-info    { --accent-bar: var(--c-info); }
.stat-card.tone-danger  { --accent-bar: var(--c-danger); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.stat-icon.si-emerald { background: var(--em-50);  color: var(--em-700); }
.stat-icon.si-purple  { background: var(--pu-50);  color: var(--pu-600); }
.stat-icon.si-gold    { background: var(--go-50);  color: var(--go-600); }
.stat-icon.si-info    { background: var(--c-info-bg); color: var(--c-info); }
.stat-icon.si-danger  { background: var(--c-danger-bg); color: var(--c-danger); }

.stat-body { flex: 1; min-width: 0; }
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ink-900);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-label { font-size: .82rem; color: var(--ink-500); margin-top: .15rem; }
.stat-delta {
    font-size: .75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    margin-top: .25rem;
    padding: .15rem .45rem;
    border-radius: var(--r-pill);
}
.delta-up   { background: var(--em-50); color: var(--em-700); }
.delta-down { background: var(--c-danger-bg); color: var(--c-danger); }
.delta-flat { background: var(--ink-100); color: var(--ink-500); }

/* — Hero/Gradient Card */
.hero-card {
    border-radius: var(--r-xl);
    padding: 2rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--sh-md);
}
.hero-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.04' fill-rule='evenodd'%3E%3Cpath d='M40 0L80 40 40 80 0 40z'/%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}
.hero-card > * { position: relative; }
.hero-card-emerald  { background: var(--grad-emerald); }
.hero-card-spiritual { background: var(--grad-spiritual); }
.hero-card-gold     { background: var(--grad-gold); }

.hero-greeting { font-size: 1.5rem; font-weight: 700; margin-bottom: .35rem; }
.hero-verse {
    font-family: 'Amiri', serif;
    font-size: 1.05rem;
    opacity: .88;
    margin-bottom: 1.25rem;
}
.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    border-radius: var(--r-pill);
    padding: .6rem 1.4rem;
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    transition: background var(--t-fast);
}
.hero-cta:hover { background: rgba(255,255,255,.28); color: #fff; }

/* ────────────────────────────────────────
   8. Buttons
──────────────────────────────────────── */
.btn-h-primary {
    background: var(--grad-emerald);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    padding: .6rem 1.25rem;
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    transition: opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
    box-shadow: var(--sh-em);
    text-decoration: none;
}
.btn-h-primary:hover  { opacity: .92; transform: translateY(-1px); color: #fff; box-shadow: 0 8px 24px rgba(15,118,110,.3); }
.btn-h-primary:active { transform: scale(.98); }

.btn-h-secondary {
    background: var(--em-50);
    color: var(--em-700);
    border: 1.5px solid var(--em-100);
    border-radius: var(--r-md);
    padding: .58rem 1.2rem;
    font-weight: 600;
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
    text-decoration: none;
}
.btn-h-secondary:hover { background: var(--em-100); border-color: var(--em-400); color: var(--em-700); }

.btn-h-gold {
    background: var(--grad-gold);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    padding: .6rem 1.25rem;
    font-weight: 600;
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    text-decoration: none;
    transition: opacity var(--t-fast);
}
.btn-h-gold:hover { opacity: .9; color: #fff; }

.btn-h-ghost {
    background: transparent;
    color: var(--ink-600);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: .58rem 1.2rem;
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    transition: background var(--t-fast);
    text-decoration: none;
}
.btn-h-ghost:hover { background: var(--ink-100); color: var(--ink-800); }

.btn-h-danger {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border: 1.5px solid #fecdd3;
    border-radius: var(--r-md);
    padding: .58rem 1.2rem;
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    transition: background var(--t-fast);
    text-decoration: none;
}
.btn-h-danger:hover { background: #ffe4e8; color: var(--c-danger); }

/* — Icon action buttons for tables */
.btn-icon {
    width: 32px; height: 32px;
    border-radius: var(--r-sm);
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .8rem;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    text-decoration: none;
    color: var(--ink-600);
}
.btn-icon:hover { background: var(--em-50); border-color: var(--em-200,#a7f3d0); color: var(--em-700); }
.btn-icon.bi-edit:hover  { background: var(--em-50); color: var(--em-700); border-color: var(--em-100); }
.btn-icon.bi-toggle:hover { background: var(--go-50); color: var(--go-600); border-color: var(--go-100); }
.btn-icon.bi-delete:hover { background: var(--c-danger-bg); color: var(--c-danger); border-color: #fecdd3; }
.btn-icon.bi-view:hover  { background: var(--pu-50); color: var(--pu-600); border-color: var(--pu-100); }

/* ────────────────────────────────────────
   9. Forms (2-column grid)
──────────────────────────────────────── */
.form-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
}
.form-2col .col-full { grid-column: 1 / -1; }

@media (max-width: 640px) {
    .form-2col { grid-template-columns: 1fr; }
    .form-2col .col-full { grid-column: 1; }
}

.field-group { display: flex; flex-direction: column; gap: .35rem; }

.field-label {
    font-size: .83rem;
    font-weight: 600;
    color: var(--ink-700);
}
.field-label .required { color: var(--c-danger); margin-right: .2rem; }

.field-control {
    height: 42px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--r-md);
    padding: 0 .85rem;
    font-size: .9rem;
    font-family: inherit;
    color: var(--ink-800);
    background: var(--c-surface);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    width: 100%;
}
.field-control:focus {
    outline: none;
    border-color: var(--em-500);
    box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}

textarea.field-control { height: auto; padding-top: .65rem; padding-bottom: .65rem; resize: vertical; }
select.field-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left .8rem center; padding-left: 2rem; }

.field-hint { font-size: .75rem; color: var(--ink-400); }
.field-error { font-size: .75rem; color: var(--c-danger); }
.field-control.is-error { border-color: var(--c-danger); }
.field-control.is-ok    { border-color: var(--em-500); }

.form-divider {
    grid-column: 1 / -1;
    border: none;
    border-top: 1px solid var(--c-border);
    margin: .5rem 0;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding-top: .5rem;
    margin-top: .25rem;
    border-top: 1px solid var(--c-border);
}

/* Bootstrap form overrides */
.form-control:focus,
.form-select:focus {
    border-color: var(--em-500);
    box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}

/* ────────────────────────────────────────
   10. Tables (DataTables-compatible)
──────────────────────────────────────── */
.dt-wrapper {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    overflow: hidden;
}

.dt-toolbar {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--c-border);
    background: var(--ink-100);
}
.dt-toolbar-title {
    font-size: .92rem;
    font-weight: 700;
    color: var(--ink-800);
    display: flex;
    align-items: center;
    gap: .5rem;
}

table.h-table { width: 100%; border-collapse: collapse; }
table.h-table thead th {
    background: var(--em-50);
    color: var(--em-700);
    font-weight: 700;
    font-size: .82rem;
    padding: .85rem .9rem;
    border-bottom: 2px solid var(--em-100);
    white-space: nowrap;
}
table.h-table thead th:first-child { border-radius: 0; }
table.h-table tbody td {
    padding: .8rem .9rem;
    font-size: .88rem;
    color: var(--ink-700);
    border-bottom: 1px solid var(--ink-100);
    vertical-align: middle;
}
table.h-table tbody tr:last-child td { border-bottom: none; }
table.h-table tbody tr:hover td { background: var(--em-50); }

/* DataTables core overrides (RTL) */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { padding: .75rem 1rem; }
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label { font-size: .85rem; color: var(--ink-600); }
.dataTables_wrapper .dataTables_filter input {
    border: 1.5px solid var(--c-border);
    border-radius: var(--r-md);
    padding: .35rem .75rem;
    font-size: .85rem;
    margin-right: .5rem;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--em-500); outline: none; }
.dataTables_wrapper .dataTables_info { padding: .75rem 1rem; font-size: .82rem; color: var(--ink-500); }
.dataTables_wrapper .dataTables_paginate { padding: .75rem 1rem; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--r-sm) !important;
    border: 1px solid var(--c-border) !important;
    padding: .3rem .7rem !important;
    font-size: .82rem !important;
    color: var(--ink-700) !important;
    background: none !important;
    margin: 0 .2rem !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--grad-emerald) !important;
    color: #fff !important;
    border-color: transparent !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) {
    background: var(--em-50) !important;
    color: var(--em-700) !important;
}
div.dataTables_processing {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    color: var(--em-700);
    font-size: .85rem;
}

/* ────────────────────────────────────────
   11. Badges & Status Pills
──────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .7rem;
    border-radius: var(--r-pill);
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
}
.pill-emerald { background: var(--em-50);  color: var(--em-700); }
.pill-purple  { background: var(--pu-50);  color: var(--pu-700); }
.pill-gold    { background: var(--go-50);  color: var(--go-600); }
.pill-info    { background: var(--c-info-bg); color: var(--c-info); }
.pill-danger  { background: var(--c-danger-bg); color: var(--c-danger); }
.pill-neutral { background: var(--ink-100); color: var(--ink-600); }

.pill::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .8;
}
.pill.no-dot::before { display: none; }

/* ────────────────────────────────────────
   12. Progress Bars & Rings
──────────────────────────────────────── */
.progress-h {
    height: 8px;
    background: var(--ink-200);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.progress-h-bar {
    height: 100%;
    border-radius: var(--r-pill);
    transition: width .6s ease;
}
.ph-emerald { background: var(--grad-emerald); }
.ph-gold    { background: var(--grad-gold); }
.ph-purple  { background: linear-gradient(90deg, var(--pu-600), var(--pu-500)); }

.renew-package-card {
    position: relative;
    cursor: pointer;
    border: 2px solid var(--c-border);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.renew-package-card:hover {
    border-color: var(--em-300);
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
}

.renew-package-card input[type="radio"] {
    position: absolute;
    inset-inline-start: 1rem;
    top: 1rem;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--em-600);
}

.renew-package-card:has(input[type="radio"]:checked) {
    border-color: var(--em-600);
    box-shadow: 0 16px 36px rgba(16,185,129,.18);
}

.renew-package-card:has(input[type="radio"]:checked) .renew-package-check {
    background: var(--grad-emerald);
    color: #fff;
    border-color: transparent;
}

.renew-package-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--em-100);
    border-radius: var(--r-md);
    background: var(--em-50);
    color: var(--em-700);
    font-weight: 700;
    font-size: .84rem;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

/* Progress ring (SVG) */
.ring-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg  { fill: none; stroke: var(--ink-200); }
.ring-fill { fill: none; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.ring-label {
    position: absolute;
    text-align: center;
    font-weight: 700;
    color: var(--ink-800);
}

/* ────────────────────────────────────────
   13. Empty State
──────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1.5rem;
    text-align: center;
}
.empty-icon {
    width: 72px; height: 72px;
    background: var(--em-50);
    color: var(--em-400);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 1.1rem;
}
.empty-title { font-size: 1rem; font-weight: 700; color: var(--ink-700); margin-bottom: .4rem; }
.empty-desc  { font-size: .86rem; color: var(--ink-500); max-width: 280px; }

/* ────────────────────────────────────────
   14. Chart Containers
──────────────────────────────────────── */
.chart-wrap {
    position: relative;
    width: 100%;
}
.chart-wrap canvas { max-width: 100%; }

/* ────────────────────────────────────────
   15. Misc Utilities
──────────────────────────────────────── */
.text-em  { color: var(--em-700) !important; }
.text-pu  { color: var(--pu-600) !important; }
.text-go  { color: var(--go-600) !important; }
.text-muted-h { color: var(--ink-500) !important; }
.fw-700   { font-weight: 700 !important; }
.fw-600   { font-weight: 600 !important; }

.border-top-em { border-top: 2px solid var(--em-100); }

.skeleton {
    background: linear-gradient(90deg, var(--ink-100) 25%, var(--ink-200) 50%, var(--ink-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--r-sm);
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ────────────────────────────────────────
   16. Responsive
──────────────────────────────────────── */
@media (max-width: 992px) {
    .hifz-sidebar {
        position: fixed;
        right: calc(-1 * var(--sidebar-w));
        top: 0;
        z-index: 1050;
        transition: right var(--t-std);
    }
    .hifz-sidebar.open { right: 0; }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1049;
        animation: fadeIn .2s ease;
    }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    .hifz-content { padding: 1.25rem 1rem; }
}

/* قصٌّ بصريّ لخلايا الأسماء الطويلة.
   اسم الحلقة قد يبلغ ستين حرفًا فيلتفّ على ثلاثة أسطر ويضغط أعمدة التواريخ بجواره.
   والقصّ هنا **عرضٌ لا بيانات**: النص كامل في DOM فيقرؤه قارئ الشاشة والنسخُ، ويظهر
   كاملًا في `title` عند التمرير.
   والحدّ بوحدة `ch` **لا بالبكسل ولا بنسبة مئوية**: النسبة داخل خلية جدولٍ تلقائيّ
   التخطيط تُحلّ على عرضٍ يعتمد على المحتوى نفسه، فتدور الحلقة ويُهمَل القيد — جُرّب
   `min(30ch, 100%)` فلم يقصّ شيئًا. و`ch` يتبع حجم الخط فيتسع بتكبيره، ويضيق على
   الجوال بنقطة الانقطاع أدناه، والجدول في `table-responsive` فما فاض يُمرَّر لا يكسر. */
.cell-truncate {
    display: inline-block;
    max-width: 30ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.cell-truncate-sm { max-width: 20ch; }

@media (max-width: 576px) {
    .stat-card { padding: 1rem; }
    .cell-truncate { max-width: 18ch; }
    .cell-truncate-sm { max-width: 14ch; }
    .stat-value { font-size: 1.4rem; }
    .hero-card { padding: 1.5rem; }
    .hero-greeting { font-size: 1.2rem; }
    .form-2col { grid-template-columns: 1fr; }
}
