/* ════════════════════════════════════════════════════════════════════
   Admin header bar — v3 (2026-05-26)
   ────────────────────────────────────────────────────────────────────
   Redesign goals: cleaner visual hierarchy, modern depth/shadows,
   unified button system (primary/ghost), more prominent Live status,
   and a polished search field. Same DOM IDs/classes so existing JS
   (refreshAdminData, adminLogout, adminSearch, toggleAdminReportsMenu)
   keeps working without a single change.
   ════════════════════════════════════════════════════════════════════ */

.admin-header-bar {
        background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
        border-bottom: 1px solid #e5e7eb;
        box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 4px 14px rgba(15, 23, 42, 0.04);
        padding: 10px 1.5rem;
        display: flex;
        align-items: center;
        gap: 16px;
        min-height: 64px;
        position: sticky;
        top: 0;
        /* Must sit ABOVE .adm-tab-bar (z-index 50). The header creates its
           own stacking context which traps the Reports-menu dropdown
           panel's z-index — if header z-index equals tab-bar z-index, the
           later-in-DOM tab bar wins and the dropdown appears clipped. */
        z-index: 60;
        backdrop-filter: saturate(140%) blur(6px);
}

/* ── Brand block ────────────────────────────────────────────────── */
.admin-header-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
        padding-right: 14px;
        border-right: 1px solid #eef0f3;
}
.admin-header-logo {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow:
                0 4px 10px rgba(15, 23, 42, 0.18),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
        position: relative;
}
.admin-header-logo::after {
        /* subtle gold ring on hover/focus for a more "premium" feel */
        content: "";
        position: absolute;
        inset: -2px;
        border-radius: 12px;
        border: 1px solid transparent;
        transition: border-color 0.2s;
}
.admin-header-bar:hover .admin-header-logo::after { border-color: rgba(251, 191, 36, 0.45); }
.admin-header-title {
        font-size: 15px;
        font-weight: 700;
        color: #0f172a;
        display: block;
        white-space: nowrap;
        line-height: 1.15;
        letter-spacing: -0.01em;
}
.admin-header-sub {
        font-size: 11px;
        color: #94a3b8;
        display: block;
        white-space: nowrap;
        line-height: 1.2;
        margin-top: 2px;
        letter-spacing: 0.01em;
}

/* ── Search ─────────────────────────────────────────────────────── */
.admin-header-search {
        position: relative;
        flex: 1;
        max-width: 360px;
        min-width: 160px;
}
.admin-header-search input {
        width: 100%;
        height: 38px;
        font-size: 13.5px;
        font-family: inherit;
        padding: 0 38px 0 14px;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        background: #f5f7fa;
        color: #0f172a;
        outline: none;
        box-sizing: border-box;
        transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.admin-header-search input::placeholder { color: #94a3b8; }
.admin-header-search input:hover  { background: #f0f3f8; }
.admin-header-search input:focus  {
        background: #ffffff;
        border-color: #fbbf24;
        box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.15);
}
.admin-search-icon {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
        opacity: 0.7;
}

/* ── Right-side action group ────────────────────────────────────── */
.admin-header-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
        flex-wrap: wrap;
        margin-left: auto;
}

/* ── Live status pill ───────────────────────────────────────────── */
.admin-last-updated {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        padding: 6px 12px;
        background: #ecfdf5;
        border: 1px solid #a7f3d0;
        color: #047857;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
        letter-spacing: 0.01em;
        transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.admin-last-updated.stale  { background: #fef9c3; border-color: #fde68a; color: #854d0e; }
.admin-last-updated.error  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.admin-live-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #10b981;
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
        animation: admin-live-pulse 2s ease-out infinite;
        flex-shrink: 0;
}
.admin-last-updated.stale .admin-live-dot { background: #eab308; animation: none; }
.admin-last-updated.error .admin-live-dot { background: #ef4444; animation: none; }
@keyframes admin-live-pulse {
        0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
        70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
        100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ── Unified header buttons ─────────────────────────────────────── */
.admin-hdr-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        height: 36px;
        padding: 0 14px;
        border-radius: 9px;
        border: 1px solid #e5e7eb;
        background: #ffffff;
        color: #334155;
        font-family: inherit;
        font-size: 12.5px;
        font-weight: 600;
        cursor: pointer;
        white-space: nowrap;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
        transition:
                background 0.15s ease,
                border-color 0.15s ease,
                color 0.15s ease,
                box-shadow 0.15s ease,
                transform 0.08s ease;
}
.admin-hdr-btn i,
.admin-hdr-btn svg { font-size: 13px; opacity: 0.9; }
.admin-hdr-btn:hover {
        background: #f8fafc;
        border-color: #cbd5e1;
        color: #0f172a;
        box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}
.admin-hdr-btn:focus-visible {
        outline: none;
        border-color: #fbbf24;
        box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.18);
}
.admin-hdr-btn:active { transform: translateY(1px); box-shadow: 0 1px 1px rgba(15, 23, 42, 0.05); }

/* Primary refresh — filled dark for "main action" emphasis */
.admin-hdr-btn.gray,
#adminRefreshBtn {
        background: #0f172a;
        border-color: #0f172a;
        color: #ffffff;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.16);
}
.admin-hdr-btn.gray:hover,
#adminRefreshBtn:hover {
        background: #1e293b;
        border-color: #1e293b;
        color: #ffffff;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}
#adminRefreshBtn.is-loading {
        background: #1e293b;
        color: #ffffff;
        pointer-events: none;
        opacity: 0.85;
}
#adminRefreshBtn.is-loading i { animation: admin-spin 0.8s linear infinite; }
@keyframes admin-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Logout — ghost button, red text, red border on hover */
.admin-hdr-btn.red {
        color: #dc2626;
        border-color: #fecaca;
        background: #fff;
}
.admin-hdr-btn.red:hover {
        background: #fef2f2;
        border-color: #fca5a5;
        color: #b91c1c;
        box-shadow: 0 2px 6px rgba(220, 38, 38, 0.10);
}

/* Reports menu trigger — neutral ghost button with caret */
.admin-hdr-btn.neutral {
        background: #fff;
        color: #334155;
        border-color: #e5e7eb;
}
.admin-hdr-btn.neutral:hover { background: #f8fafc; color: #0f172a; }
.admin-hdr-caret {
        font-size: 10px !important;
        margin-left: 2px;
        opacity: 0.55;
        transition: transform 0.18s;
}
.admin-hdr-menu[aria-expanded="true"] .admin-hdr-caret,
.admin-hdr-menu-trigger[aria-expanded="true"] .admin-hdr-caret {
        transform: rotate(180deg);
}

/* Legacy colour variants kept for any other call-sites; visually merged
   into the unified ghost-button style so the header stays cohesive. */
.admin-hdr-btn.green,
.admin-hdr-btn.blue,
.admin-hdr-btn.teal,
.admin-hdr-btn.amber,
.admin-hdr-btn.purple {
        background: #fff;
        border-color: #e5e7eb;
        color: #334155;
}
.admin-hdr-btn.green:hover  { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.admin-hdr-btn.blue:hover   { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.admin-hdr-btn.teal:hover   { background: #f0fdfa; color: #0f766e; border-color: #99f6e4; }
.admin-hdr-btn.amber:hover  { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.admin-hdr-btn.purple:hover { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1024px) {
        .admin-header-bar { gap: 12px; padding: 10px 1.25rem; }
        .admin-header-search { max-width: 280px; }
        .admin-header-sub { display: none; }
}
@media (max-width: 900px) {
        .admin-header-bar {
                flex-wrap: wrap;
                padding: 10px 1rem;
                gap: 10px;
                min-height: 0;
        }
        .admin-header-brand { border-right: 0; padding-right: 0; }
        .admin-header-search {
                order: 3;
                max-width: 100%;
                flex-basis: 100%;
        }
        .admin-header-actions {
                gap: 6px;
                margin-left: auto;
        }
}
@media (max-width: 600px) {
        .admin-header-bar { padding: 8px 0.75rem; gap: 8px; min-height: 56px; }
        .admin-header-logo { width: 34px; height: 34px; border-radius: 9px; }
        .admin-header-title { font-size: 13.5px; }
        .admin-hdr-btn {
                height: 36px;
                padding: 0 12px;
                font-size: 11.5px;
                gap: 5px;
                border-radius: 9px;
        }
        .admin-hdr-btn i,
        .admin-hdr-btn svg { font-size: 13px; }
        .admin-last-updated { padding: 4px 10px; font-size: 11px; }
        .admin-header-search input { height: 34px; font-size: 12.5px; }
}

/* Narrow phones — icon-only mode for the three action buttons. The
   icons render as circular tappable targets, 38×38, equal visual weight
   so Reports / Refresh / Logout look like a coherent button group. The
   chevron caret on Reports is the only differentiator. */
@media (max-width: 480px) {
        .admin-header-bar { gap: 6px; padding: 8px 12px; }
        .admin-header-actions { gap: 6px; flex-wrap: nowrap; }
        .admin-hdr-btn span { display: none; }
        .admin-hdr-btn {
                width: 38px;
                height: 38px;
                padding: 0;
                justify-content: center;
                border-radius: 10px;
                flex: 0 0 38px;
        }
        .admin-hdr-btn i,
        .admin-hdr-btn svg { font-size: 14px; }
        /* Reports button still shows its caret — but small and tucked
           against the icon so the button stays square. */
        .admin-hdr-caret {
                position: absolute;
                bottom: 2px;
                right: 2px;
                font-size: 7px !important;
                opacity: 0.65;
        }
        .admin-hdr-menu-trigger { position: relative; }
        /* Live pill collapses to just the pulsing dot — no text. */
        .admin-last-updated .admin-last-updated-text { display: none; }
        .admin-last-updated {
                padding: 0;
                width: 38px;
                height: 38px;
                border-radius: 10px;
                justify-content: center;
                flex: 0 0 38px;
        }
        .admin-live-dot { width: 10px; height: 10px; }
        /* The dropdown should hug the right edge on phones and never
           overflow the viewport. */
        .admin-hdr-menu-panel {
                right: 0 !important;
                left: auto !important;
                min-width: 240px !important;
                max-width: calc(100vw - 24px) !important;
        }
        /* Wordmark stays visible but compact — keep the brand readable. */
        .admin-header-brand {
                border-right: 0;
                padding-right: 0;
                gap: 8px;
        }
        .admin-header-title { font-size: 12.5px; }
}

/* Extra-small phones — tighten further so the three buttons fit
   alongside the brand without horizontal scrolling. */
@media (max-width: 380px) {
        .admin-header-bar { padding: 6px 8px; gap: 4px; }
        .admin-hdr-btn,
        .admin-last-updated {
                width: 34px;
                height: 34px;
                flex: 0 0 34px;
        }
        .admin-header-actions { gap: 4px; }
}

.admin-body {
        max-width: 1400px;
        margin: 0 auto;
        padding: 24px;
}
.stat-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 16px;
        margin-bottom: 28px;
}
.stat-card {
        background: #fff;
        border-radius: 16px;
        padding: 20px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
        border-left: 4px solid #fbbf24;
}
.stat-card .sval {
        font-size: 32px;
        font-weight: 700;
        color: #0f172a;
}
.stat-card .slabel {
        font-size: 13px;
        color: #64748b;
        margin-top: 4px;
}
.admin-section {
        background: #fff;
        border-radius: 16px;
        padding: 24px;
        margin-bottom: 20px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
        -webkit-overflow-scrolling: touch;
}
.admin-section h3 {
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 16px;
        color: #0f172a;
        border-bottom: 2px solid #f1f5f9;
        padding-bottom: 10px;
}
/* ── Admin Data Tables ────────────────────────────────── */
.atbl {
        width: 100%;
        border-collapse: collapse;
        font-size: 13px;
        border-spacing: 0;
}
.atbl th {
        background: linear-gradient(90deg, #f8fafc, #f1f5f9);
        padding: 12px 14px;
        text-align: left;
        font-weight: 700;
        color: #334155;
        border-bottom: 2px solid #e2e8f0;
        white-space: nowrap;
        position: sticky;
        top: 0;
        z-index: 2;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
}
.atbl td {
        padding: 12px 14px;
        border-bottom: 1px solid #f1f5f9;
        vertical-align: middle;
        white-space: normal;
        word-break: break-word;
        hyphens: auto;
        line-height: 1.5;
        max-width: 220px;
}
.atbl td[data-label="#"],
.atbl td[data-label="Outcomes"],
.atbl td[data-label="Sessions"],
.atbl td[data-label="Cont. Hrs"],
.atbl td[data-label="Hours"],
.atbl td[data-label="Type"],
.atbl td[data-label="Credits"],
.atbl td[data-label="Paid"],
.atbl td[data-label="Amount"],
.atbl td[data-label="Status"] {
        white-space: nowrap;
        text-align: center;
}
.atbl tr:hover td {
        background: #fffbeb;
        transition: background 0.15s ease;
}
.atbl tr:nth-child(even) td {
        background: #fafbfc;
}
.atbl tr:nth-child(even):hover td {
        background: #fffbeb;
}
.badge-ok {
        background: #dcfce7;
        color: #166534;
        padding: 3px 10px;
        border-radius: 20px;
        font-size: 11px;
        font-weight: 600;
}
.badge-used {
        background: #fee2e2;
        color: #991b1b;
        padding: 3px 10px;
        border-radius: 20px;
        font-size: 11px;
        font-weight: 600;
}
.badge-pend {
        background: #fef3c7;
        color: #92400e;
        padding: 3px 10px;
        border-radius: 20px;
        font-size: 11px;
        font-weight: 600;
}
.quota-bar {
        background: #e2e8f0;
        border-radius: 10px;
        height: 8px;
        width: 80px;
        overflow: hidden;
}
.quota-fill {
        background: #fbbf24;
        height: 100%;
        border-radius: 10px;
        transition: width 0.3s;
}
.header {
        background: linear-gradient(135deg, #0a0f1e 0%, #0f172a 60%, #1a2540 100%);
        padding: 14px 32px;
        border-bottom: 3px solid transparent;
        border-image: linear-gradient(90deg, #f59e0b, #fbbf24, #fde68a, #fbbf24) 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow:
                0 4px 24px rgba(0, 0, 0, 0.25),
                0 1px 0 rgba(251, 191, 36, 0.15);
        position: relative;
}
.header::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.5), transparent);
}
.logo h1 {
        font-size: 20px;
        font-weight: 800;
        color: #fbbf24;
        margin-bottom: 2px;
        letter-spacing: -0.3px;
        font-family: "Playfair Display", serif;
}
.logo p {
        font-size: 12px;
        color: #94a3b8;
}
/* ══ HEADER-RIGHT — base (all screens) ══ */
.header-right {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
}
/* ── ENHANCED ADMIN DASHBOARD v2.0 ── */

.admin-dashboard {
    max-width: 1480px;
    margin: 0 auto;
    padding: 24px;
}

.admin-nav-tabs {
    display: flex;
    background: #fff;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 4px;
}

.admin-tab {
    flex: 1;
    padding: 14px 20px;
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.admin-tab.active {
    background: #0f172a;
    color: #fbbf24;
    box-shadow: 0 4px 12px rgba(15,23,42,0.15);
}

.admin-tab i {
    font-size: 16px;
}

/* KPI Cards - Modern Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border-left: 6px solid #fbbf24;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-8px);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(251,191,36,0.15) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #fbbf24;
}

.kpi-value {
    font-size: 2.8rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
    margin: 8px 0 4px;
}

.kpi-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-trend {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.kpi-trend.up {
    background: #dcfce7;
    color: #166534;
}

.kpi-trend.down {
    background: #fee2e2;
    color: #991b1b;
}

/* Revenue Breakdown */
.revenue-section {
    background: #fff;
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 32px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}

.revenue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

/* New Signups */
.new-signups {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: white;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 32px;
}

.new-signup-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.new-signup-item:last-child {
    border-bottom: none;
}

.new-signup-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fbbf24;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

/* Improved Tables — container for responsive scrolling */
.admin-table-container {
    overflow-x: auto;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
    background: white;
    -webkit-overflow-scrolling: touch;
}

/* Note: .atbl base styles are defined above — no duplicate here */

/* Sticky first column for horizontal scroll */
.atbl th:first-child,
.atbl td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: inherit;
}
.atbl th:first-child {
    z-index: 4;
    background: linear-gradient(90deg, #f8fafc, #f1f5f9);
}
.atbl td:first-child {
    background: inherit;
    font-weight: 600;
    color: #475569;
}
.atbl tr:nth-child(even) td:first-child {
    background: #fafbfc;
}
.atbl tr:hover td:first-child,
.atbl tr:nth-child(even):hover td:first-child {
    background: #fffbeb;
}

/* Admin action buttons row — compact on all sizes */
.atbl td[data-label="Actions"] {
    white-space: nowrap;
    max-width: none;
}
.admin-action-btn {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
}
.admin-action-btn:active {
    transform: scale(0.95);
}
.admin-credit-input {
    width: 48px;
    padding: 4px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
    margin: 0 2px;
}

/* Institution badge in table */
.inst-badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

/* ── Responsive Table: Tablet (≤900px) ─────────────────── */
@media (max-width: 900px) {
    .atbl th,
    .atbl td {
        padding: 10px 10px;
        font-size: 12px;
    }
    .atbl td {
        max-width: 160px;
    }
    /* Hide less-critical columns on tablet */
    .atbl th:nth-child(7),
    .atbl td:nth-child(7) { /* Last Login */
        display: none;
    }
    #paymentsTable th:nth-child(5),
    #paymentsTable td:nth-child(5) { /* Submitted date */
        display: none;
    }
}

/* ── Responsive Table: Mobile card layout (≤640px) ──────── */
@media (max-width: 640px) {
    .admin-section {
        padding: 16px;
        border-radius: 12px;
    }
    .admin-section h3 {
        font-size: 14px;
        margin-bottom: 12px;
    }
    /* Table container takes full width */
    .admin-section > div[style*="overflow"] {
        overflow-x: visible;
        width: 100%;
    }
    /* Hide table headers on mobile — cards show labels via data-label */
    .atbl thead {
        display: none;
    }
    /* Convert each row into a card */
    .atbl,
    .atbl tbody,
    .atbl tr,
    .atbl td {
        display: block;
        width: 100%;
    }
    .atbl tr {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 14px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
        position: relative;
        overflow: hidden;
    }
    .atbl tr:hover td,
    .atbl tr:nth-child(even) td,
    .atbl tr:nth-child(even):hover td {
        background: transparent;
    }
    /* Each cell becomes a label-value row inside the card */
    .atbl td {
        padding: 5px 0;
        border-bottom: none;
        max-width: 100% !important;
        white-space: normal !important;
        text-align: left !important;
        position: static !important;
        background: transparent !important;
        line-height: 1.5;
        font-size: 13px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 8px;
    }
    .atbl td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #64748b;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        min-width: 90px;
        flex-shrink: 0;
        padding-top: 1px;
    }
    /* First cell (#) becomes card header with name */
    .atbl td[data-label="#"]::before {
        display: none;
    }
    .atbl td[data-label="#"] {
        display: none;
    }
    /* Name cell becomes the card title */
    .atbl td[data-label="Name"]::before {
        display: none;
    }
    .atbl td[data-label="Name"] {
        font-size: 15px;
        font-weight: 700;
        color: #0f172a;
        padding-bottom: 8px;
        margin-bottom: 4px;
        border-bottom: 1px solid #f1f5f9;
    }
    /* User cell (payments/generations) becomes card title */
    .atbl td[data-label="User"]::before {
        display: none;
    }
    .atbl td[data-label="User"] {
        font-size: 14px;
        font-weight: 700;
        color: #0f172a;
        padding-bottom: 6px;
        margin-bottom: 2px;
        border-bottom: 1px solid #f1f5f9;
    }
    .atbl td[data-label="User"] small {
        font-weight: 400;
        color: #64748b;
        font-size: 12px;
    }
    /* Actions row — full width button group */
    .atbl td[data-label="Actions"] {
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px solid #f1f5f9;
        justify-content: flex-start;
    }
    .atbl td[data-label="Actions"]::before {
        display: none;
    }
    /* Unit cell (generations) — full width for long text */
    .atbl td[data-label="Unit"] {
        flex-direction: column;
        gap: 2px;
    }
    .atbl td[data-label="Unit"]::before {
        align-self: flex-start;
    }
    /* M-Pesa Ref — monospace for codes */
    .atbl td[data-label="M-Pesa Ref"] {
        font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
        font-size: 12px;
        letter-spacing: 0.5px;
    }
    /* Unit Generated — allow wrapping for long names */
    .atbl td[data-label="Unit Generated"] {
        flex-direction: column;
        gap: 2px;
    }
    .atbl td[data-label="Unit Generated"]::before {
        align-self: flex-start;
    }
    /* Status badge styling */
    .atbl td[data-label="Status"] {
        justify-content: flex-start;
    }
}

/* ── Responsive Table: Very small mobile (≤380px) ──────── */
@media (max-width: 380px) {
    .atbl tr {
        padding: 10px;
        border-radius: 10px;
        margin-bottom: 8px;
    }
    .atbl td {
        font-size: 12px;
        padding: 4px 0;
    }
    .atbl td::before {
        font-size: 10px;
        min-width: 75px;
    }
    .atbl td[data-label="Name"] {
        font-size: 14px;
    }
    .admin-action-btn {
        font-size: 10px;
        padding: 4px 8px;
    }
    .admin-credit-input {
        width: 40px;
        font-size: 11px;
    }
}

/* Export buttons */
.export-btns {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.export-btn {
    background: #0f172a;
    color: #fbbf24;
    border: none;
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.export-btn:hover {
    background: #1e293b;
    transform: translateY(-2px);
}
