@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
    --navy: #061f3f;
    --navy-2: #082b55;
    --blue: #2563eb;
    --cyan: #00b4d8;
    --bg: #f3f7fb;
    --card: #ffffff;
    --text: #0f1f35;
    --muted: #64748b;
    --border: #d9e4f2;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --purple: #7c3aed;
    --teal: #0f766e;
    --shadow: 0 18px 45px rgba(6, 31, 63, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Inter", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.admin-shell {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: linear-gradient(180deg, #041b38, #062a55);
    color: white;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 4px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 5px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.25);
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand h2 {
    margin: 0;
    font-size: 23px;
    color: white;
}

.brand p {
    margin: 2px 0 0;
    color: rgba(255,255,255,0.58);
    font-size: 12px;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.side-nav a {
    color: rgba(255,255,255,0.78);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 14px;
    font-weight: 700;
    transition: 0.2s ease;
}

.side-nav a:hover,
.side-nav a.active {
    color: white;
    background: rgba(37,99,235,0.65);
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}

.sidebar-footer {
    margin-top: auto;
}

.admin-mini {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 14px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: white;
    color: var(--navy);
    font-weight: 800;
}

.admin-mini strong {
    display: block;
    font-size: 13px;
}

.admin-mini small {
    display: block;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
}

.main-area {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 22px 34px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: -0.04em;
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
    font-size: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 6px rgba(34,197,94,0.12);
}

.content {
    width: min(1500px, 94%);
    margin: 28px auto 60px;
}

.panel {
    background: rgba(255,255,255,0.66);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 24px;
    padding: 24px;
    margin-top: 24px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.section-head h2,
.panel h2 {
    margin: 0;
    color: var(--navy);
    font-size: 23px;
    letter-spacing: -0.03em;
}

.section-head p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.section-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.card {
    background: white;
    padding: 24px;
    border-radius: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(var(--blue), var(--cyan));
}

.card p {
    margin: 0;
    color: var(--muted);
    font-weight: 600;
}

.card h2 {
    margin: 10px 0 0;
    color: var(--navy);
    font-size: 34px;
    letter-spacing: -0.05em;
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
}

.toolbar input,
.toolbar select,
input,
select {
    min-height: 46px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.toolbar input {
    grid-column: span 6;
}

.toolbar select {
    grid-column: span 2;
}

.toolbar button {
    grid-column: span 1;
}

.payment-toolbar input {
    grid-column: span 4;
}

.payment-toolbar input[type="date"] {
    grid-column: span 2;
}

.payment-toolbar select {
    grid-column: span 2;
}

input:focus,
select:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 4px rgba(0,180,216,0.12);
}

button {
    border: none;
    border-radius: 13px;
    padding: 13px 18px;
    min-height: 46px;
    font-weight: 800;
    cursor: pointer;
    color: white;
    background: var(--navy);
    transition: 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue), var(--cyan));
}

.btn-secondary {
    background: white;
    color: var(--navy);
    border: 1px solid var(--border);
}

.logout-btn {
    width: 100%;
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.view {
    background: var(--teal);
}

.danger,
.btn-danger {
    background: var(--danger);
}

.btn-success {
    background: var(--success);
}

.btn-reset {
    background: var(--purple);
}

.table-wrap {
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 10px 28px rgba(6, 31, 63, 0.05);
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 1050px;
    border-collapse: collapse;
    background: white;
}

th,
td {
    padding: 16px 18px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fbff;
    color: #334155;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

tbody tr:hover {
    background: #f8fbff;
}

td button {
    margin: 3px;
    padding: 10px 14px;
    min-height: 38px;
    border-radius: 11px;
}

.badge {
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: lowercase;
}

.active {
    background: #dcfce7;
    color: #166534;
}

.expired {
    background: #fee2e2;
    color: #991b1b;
}

.suspended {
    background: #fef3c7;
    color: #92400e;
}

.pending_activation {
    background: #dbeafe;
    color: #1e40af;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: white;
    border-top: 1px solid var(--border);
}

.pagination span {
    color: var(--muted);
    font-weight: 800;
}

.loading {
    padding: 24px;
    color: var(--muted);
}

/* MODALS */
.modal-overlay,
.plan-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 31, 63, 0.65);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    overflow: auto;
}

.modal-window,
.plan-modal-window {
    background: white;
    width: 720px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 24px;
    box-shadow: 0 28px 90px rgba(0,0,0,0.30);
}

.modal-header,
.plan-modal-header {
    padding: 22px 26px;
    background: linear-gradient(135deg, var(--navy), var(--navy-2));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2,
.plan-modal-header h2 {
    margin: 0;
    color: white;
}

.modal-close,
.plan-modal-close {
    background: rgba(255,255,255,0.12);
    color: white;
    font-size: 26px;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
}

.modal-body,
.plan-modal-body {
    padding: 28px;
}

.modal-body label,
.plan-modal-body label {
    display: block;
    margin: 14px 0 6px;
    font-weight: 800;
    color: var(--navy);
}

.modal-body input,
.modal-body select,
.plan-modal-body input {
    width: 100%;
}

.modal-grid,
.plan-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.modal-actions,
.plan-modal-footer {
    margin-top: 28px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.secondary,
.cancel {
    background: #64748b !important;
}

.primary,
.save {
    background: var(--navy) !important;
}

/* OLD LOGIN PAGE SUPPORT */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: white;
    padding: 42px;
    border-radius: 22px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-logo {
    width: 120px;
    margin-bottom: 20px;
}

.login-card input {
    width: 100%;
    margin-top: 15px;
}

.password-field {
    position: relative;
    width: 100%;
    margin-top: 15px;
}

.login-card .password-field input {
    margin-top: 0;
    padding-right: 44px;
}

.login-card .password-field .toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    min-height: unset;
    padding: 0;
    margin: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.login-card .password-field .toggle-password:hover {
    background: var(--bg);
    color: var(--navy);
    transform: translateY(-50%);
}

/* Visually hidden but still announced by screen readers - keeps the
   existing placeholder-only visual design while giving inputs a real
   accessible name. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.login-card button {
    width: 100%;
    margin-top: 20px;
}

.login-card .link-button {
    background: none;
    border: none;
    color: var(--accent, #0a7cff);
    text-decoration: underline;
    cursor: pointer;
    margin-top: 10px;
    padding: 0;
    font-size: 14px;
}

#loginError {
    color: var(--danger);
    margin-top: 15px;
}

@media (max-width: 1050px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    .side-nav {
        flex-direction: row;
        min-width: max-content;
    }

    .sidebar-footer {
        margin-top: 0;
        margin-left: auto;
        min-width: 170px;
    }

    .admin-mini {
        display: none;
    }

    .topbar {
        position: relative;
    }
}

@media (max-width: 760px) {
    /* iOS Safari auto-zooms on focus for any input under 16px, which
       misaligns the layout until the user manually zooms back out. */
    input,
    select {
        font-size: 16px;
    }

    .login-card {
        padding: 30px 22px;
    }

    .content {
        width: 94%;
    }

    .topbar {
        padding: 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .section-head {
        flex-direction: column;
    }

    .toolbar,
    .payment-toolbar {
        grid-template-columns: 1fr;
    }

    .toolbar input,
    .toolbar select,
    .toolbar button,
    .payment-toolbar input,
    .payment-toolbar input[type="date"],
    .payment-toolbar select {
        grid-column: span 1;
        width: 100%;
    }

    button {
        width: 100%;
    }

    .pagination button {
        width: auto;
    }

    th,
    td {
        padding: 14px;
    }
}

/* ---------- Moniepoint Transfer review queue ---------- */
.mp-transfer-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fffbeb;
    border: 1.5px solid var(--warning);
    color: #92400e;
    border-radius: 12px;
    padding: 12px 16px;
    margin: 14px 0;
    font-weight: 700;
    font-size: 13.5px;
}
.mp-transfer-empty {
    text-align: center;
    color: var(--muted);
    padding: 28px !important;
}
.mp-transfer-mono {
    font-family: "Courier New", monospace;
    font-size: 13px;
}
.mp-transfer-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
