/* ── Admin header bar ────────────────────────────────────────── */
.admin-header-bar {
        background: #fff;
        border-bottom: 1px solid #e5e7eb;
        padding: 0 1.25rem;
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 54px;
}
.admin-header-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
}
.admin-header-logo {
        width: 34px;
        height: 34px;
        border-radius: 8px;
        background: #0f172a;
        display: flex;
        align-items: center;
        justify-content: center;
}
.admin-header-title {
        font-size: 14px;
        font-weight: 700;
        color: #111827;
        display: block;
        white-space: nowrap;
        line-height: 1.2;
}
.admin-header-sub {
        font-size: 11px;
        color: #9ca3af;
        display: block;
        white-space: nowrap;
        line-height: 1.2;
}
.admin-header-search {
        position: relative;
        flex: 1;
        max-width: 260px;
        min-width: 120px;
}
.admin-header-search input {
        width: 100%;
        height: 34px;
        font-size: 13px;
        padding: 0 32px 0 12px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #f9fafb;
        color: #111827;
        outline: none;
        box-sizing: border-box;
        transition: border-color 0.15s;
}
.admin-header-search input:focus {
        border-color: #fbbf24;
        box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.1);
}
.admin-search-icon {
        position: absolute;
        right: 9px;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
}
.admin-header-actions {
        display: flex;
        align-items: center;
        gap: 5px;
        flex-shrink: 0;
        flex-wrap: wrap;
}
.admin-hdr-btn {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        height: 32px;
        padding: 0 8px;
        border-radius: 7px;
        border: 1px solid transparent;
        background: transparent;
        font-size: 11px;
        font-weight: 600;
        cursor: pointer;
        transition:
                background 0.15s,
                transform 0.1s;
        white-space: nowrap;
}
.admin-hdr-btn:active {
        transform: scale(0.96);
}
.admin-hdr-btn.green {
        border-color: #bbf7d0;
        color: #16a34a;
}
.admin-hdr-btn.green:hover {
        background: #f0fdf4;
}
.admin-hdr-btn.blue {
        border-color: #bfdbfe;
        color: #2563eb;
}
.admin-hdr-btn.blue:hover {
        background: #eff6ff;
}
.admin-hdr-btn.teal {
        border-color: #99f6e4;
        color: #0d9488;
}
.admin-hdr-btn.teal:hover {
        background: #f0fdfa;
}
.admin-hdr-btn.amber {
        border-color: #fde68a;
        color: #d97706;
}
.admin-hdr-btn.amber:hover {
        background: #fffbeb;
}
.admin-hdr-btn.purple {
        border-color: #ddd6fe;
        color: #7c3aed;
}
.admin-hdr-btn.purple:hover {
        background: #f5f3ff;
}
.admin-hdr-btn.gray {
        border-color: #e5e7eb;
        color: #475569;
}
.admin-hdr-btn.gray:hover {
        background: #f3f4f6;
}
.admin-hdr-btn.red {
        border-color: #fecaca;
        color: #dc2626;
}
.admin-hdr-btn.red:hover {
        background: #fef2f2;
}
@media (max-width: 900px) {
        .admin-header-bar {
                flex-wrap: wrap;
                padding: 10px 1rem;
                gap: 8px;
        }
        .admin-header-search {
                order: 3;
                max-width: 100%;
                flex-basis: 100%;
        }
        .admin-header-actions {
                flex-wrap: wrap;
                gap: 4px;
        }
}
@media (max-width: 600px) {
        .admin-header-bar {
                padding: 8px 0.75rem;
                gap: 6px;
        }
        .admin-header-logo {
                width: 28px;
                height: 28px;
        }
        .admin-hdr-btn {
                height: 28px;
                padding: 0 6px;
                font-size: 10px;
                gap: 3px;
                border-radius: 6px;
        }
        .admin-hdr-btn svg {
                width: 12px;
                height: 12px;
        }
        .admin-header-search input {
                height: 30px;
                font-size: 12px;
        }
}
@media (max-width: 380px) {
        .admin-hdr-btn span {
                display: none;
        }
        .admin-hdr-btn {
                padding: 0;
                width: 30px;
                justify-content: center;
        }
}

.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);
}
