:root {
    --bg: #f8fafc;
    --sidebar: #ffffff;
    --card: #ffffff;
    --glass: rgba(0, 0, 0, 0.02);
    --border: rgba(0, 0, 0, 0.08);
    --text: #1e293b;
    --muted: #64748b;
    --accent: #f5a623;
    --green: #10b981;
    --danger: #ef4444;
    --blue: #3b82f6;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body.dark-mode {
    --bg: #0f1219;
    --sidebar: #151a23;
    --card: #1b2230;
    --glass: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.12);
    --text: #e8edf7;
    --muted: rgba(232, 237, 247, 0.65);
    --accent: #f5a623;
    --green: #3cb878;
    --danger: #ef5350;
    --blue: #42a5f5;
    --card-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "DM Sans", sans-serif;
    background: var(--bg);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background: radial-gradient(circle at 10% 0%, #1f2738, #0f1219 45%);
}

.container {
    width: min(1160px, 94%);
    margin: 0 auto;
}

.row {
    display: flex;
    align-items: center;
}

.between {
    justify-content: space-between;
}

.topbar {
    background: rgba(15, 18, 25, 0.88);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px 0;
}

.brand {
    color: var(--text);
    text-decoration: none;
    font-family: "Playfair Display", serif;
    font-weight: 800;
    letter-spacing: 0.2px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.brand-logo {
    height: 34px;
    width: auto;
    display: block;
}

.brand-name {
    display: inline-block;
}

.nav-avatar-link {
    margin-left: auto;
    margin-right: 10px;
}

.nav-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, .3);
}

.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .06);
    color: #fff;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.nav-toggle:hover {
    border-color: rgba(245, 166, 35, .7);
    color: var(--accent);
}

.nav a {
    color: var(--muted);
    margin-left: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color .2s ease;
}

.nav a:hover {
    color: var(--accent);
}

/* Nav Groups & Dropdown */
.nav {
    display: flex;
    align-items: center;
}

.nav-dropdown {
    position: relative;
    display: inline-block;
    margin-left: 20px;
}

.nav-dropdown-trigger {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-dropdown:hover .nav-dropdown-trigger {
    color: var(--accent);
}

.nav-dropdown-content {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 200px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, .4);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    margin-top: 5px;
    backdrop-filter: blur(10px);
}

.nav-dropdown:hover .nav-dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.admin-table-wrapper {
    overflow: visible;
}

@media (max-width: 992px) {
    .admin-table-wrapper {
        overflow-x: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .admin-table-wrapper::-webkit-scrollbar {
        display: none;
    }
}

.nav-dropdown-content a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    margin: 0 !important;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-dropdown-content a i {
    width: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

.nav-dropdown-content a:hover {
    background: rgba(245, 166, 35, .08);
    color: var(--accent);
}

.nav-dropdown-content a:hover i {
    color: var(--accent);
}

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

.mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(1, 4, 10, .62);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity .24s ease;
}

.mobile-nav-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: min(320px, 88vw);
    height: 100vh;
    background: linear-gradient(170deg, #161f2c, #0f1621);
    border-left: 1px solid rgba(255, 255, 255, .14);
    box-shadow: -18px 0 50px rgba(0, 0, 0, .45);
    z-index: 999;
    transition: right .26s ease;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mobile-nav-open .mobile-nav-overlay {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-open .mobile-nav-drawer {
    right: 0;
}

.mobile-nav-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-nav-logo {
    height: 34px;
    width: auto;
}

.mobile-nav-close {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .07);
    color: #fff;
    cursor: pointer;
}

.admin-top-nav .nav {
    justify-content: flex-start;
}

.admin-top-nav .nav a {
    margin-right: 20px;
    margin-left: 0;
}

.admin-top-nav .nav-dropdown {
    margin-right: 20px;
    margin-left: 0;
}

.admin-top-nav .nav-dropdown-trigger {
    gap: 8px;
    font-size: 0.88rem;
}

.admin-top-nav .nav-dropdown-content {
    right: auto;
    left: 0;
    min-width: 220px;
}

@media (max-width: 768px) {
    .admin-top-nav .nav {
        flex-wrap: wrap;
        gap: 15px;
    }
}

.mobile-nav-links {
    display: grid;
    gap: 8px;
}

.mobile-nav-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    text-decoration: none;
    color: var(--text);
    background: var(--glass);
    font-size: .92rem;
    font-weight: 600;
}

.mobile-nav-links a:hover {
    border-color: rgba(245, 166, 35, .8);
    color: var(--accent);
}

.main {
    padding: 28px 0 42px;
    flex: 1;
    width: min(1160px, 94%);
}

.main.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
}

.card,
.subcard {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--card-shadow);
}

.subcard {
    padding: 14px;
}

.card {
    margin-bottom: 14px;
}

.grid {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

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

.grid.four {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

h1,
h2,
h3 {
    font-family: "Playfair Display", serif;
    margin-top: 0;
}

label {
    display: block;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--muted);
    margin: 8px 0 6px;
}

.field-help {
    display: block;
    font-size: .72rem;
    color: #b8c7da;
    margin-top: 4px;
    line-height: 1.35;
    text-transform: none;
    letter-spacing: 0;
}

input,
select,
textarea,
button {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    color: var(--text);
    font-family: "DM Sans", sans-serif;
}

select option {
    background: #121a25;
    color: #e8edf7;
}

textarea {
    min-height: 90px;
}

form {
    display: grid;
    gap: 10px;
}

form button {
    margin-top: 6px;
}

button,
.btn {
    background: linear-gradient(135deg, #f5a623, #ff8f00);
    color: #101318;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

button:hover,
.btn:hover {
    filter: brightness(1.07);
}

.btn.light {
    background: linear-gradient(135deg, #2d3748, #1f2738);
    color: #fff;
}

button.danger,
.danger {
    background: linear-gradient(135deg, #e53935, #b71c1c);
    color: #fff;
}

.inline {
    display: inline-block;
}

.inline button {
    width: auto;
    padding: 8px 12px;
}

.amount {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--accent);
    font-family: "Playfair Display", serif;
}

code {
    background: rgba(255, 255, 255, .08);
    padding: 2px 6px;
    border-radius: 6px;
    color: #ffd58d;
}

.alert {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(66, 165, 245, .17);
    color: #9ad4ff;
}

.alert.error {
    background: rgba(239, 83, 80, .18);
    color: #ff5252;
}

body.dark-mode .alert.error {
    color: #ffc7c4;
}

/* Theme Toggle styles */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    margin-left: 10px;
}

.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 48px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    background-color: #fff;
    bottom: 4px;
    content: "";
    height: 16px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 16px;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.slider .icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #666;
    pointer-events: none;
    z-index: 1;
}

.slider .sun {
    left: 7px;
}

.slider .moon {
    right: 7px;
    color: #fff;
    opacity: 0;
}

input:checked+.slider .sun {
    opacity: 0;
}

input:checked+.slider .moon {
    opacity: 1;
}

/* Minimal Stat Cards */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: var(--glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--accent);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin: 0;
    font-family: "DM Sans", sans-serif;
    font-weight: 700;
}

.stat-info .amount {
    font-size: 1.4rem;
    margin: 2px 0 0;
    color: var(--text);
    font-weight: 800;
    line-height: 1;
    font-family: "Playfair Display", serif;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-nav a {
    text-decoration: none;
    color: var(--text);
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: .85rem;
}

.admin-nav a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: .67rem;
    color: var(--muted);
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
    color: var(--text);
}

tr:hover td {
    background: var(--glass);
}

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

.actions .mini {
    width: auto;
    padding: 6px 10px;
    font-size: .75rem;
    border-radius: 8px;
}

.actions .ghost {
    background: var(--glass);
    color: var(--text);
    border: 1px solid var(--border);
}

.actions .ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 14, 0.78);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 14px;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    width: min(620px, 96%);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--sidebar);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.close-modal {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    border: 1px solid var(--border);
}

.narrow {
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

.auth-card h1 {
    margin-bottom: 8px;
}

.auth-help {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: .86rem;
}

.auth-link {
    color: #9ad4ff;
    text-decoration: none;
}

.auth-link:hover {
    color: var(--accent);
}

.site-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, .12);
    background: rgba(8, 12, 18, .72);
}

.site-footer-inner {
    padding: 18px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-brand img {
    height: 38px;
    width: auto;
}

.footer-copy {
    font-size: .82rem;
    color: #9fb2c5;
}

.footer-tag {
    font-size: .8rem;
    color: #9fb2c5;
}

.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
}

.quick-action-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: linear-gradient(150deg, rgba(60, 184, 120, .22), rgba(25, 35, 49, .55));
    color: #f4f8ff;
    transition: transform .2s ease, border-color .2s ease;
}

.quick-action-card i {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 166, 35, .2);
    color: var(--accent);
}

.quick-action-card strong {
    font-size: .9rem;
}

.quick-action-card small {
    color: #bed0e6;
    font-size: .75rem;
}

.quick-action-card:hover {
    transform: translateY(-2px);
    border-color: rgba(245, 166, 35, .7);
}

.profile-mini-link {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(255, 255, 255, .08);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.profile-mini-link:hover {
    color: var(--accent);
    border-color: rgba(245, 166, 35, .8);
}

.withdraw-account-link {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(245, 166, 35, .45);
    background: linear-gradient(135deg, rgba(245, 166, 35, .22), rgba(255, 143, 0, .16));
    color: #ffe2b1;
    text-decoration: none;
    font-weight: 700;
}

.withdraw-account-link:hover {
    color: #fff2da;
    border-color: rgba(245, 166, 35, .85);
}

.activity-chat {
    display: grid;
    gap: 10px;
    max-height: 340px;
    overflow-y: auto;
    padding-right: 4px;
}

.activity-msg {
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 12px;
    padding: 10px 12px;
}

.activity-msg .meta {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: #9fb2c5;
    margin-bottom: 4px;
}

.activity-msg .text {
    font-size: .86rem;
    color: #d9e3f2;
}

.stats-grid {
    gap: 12px;
}

.stat-card h3 {
    font-size: .92rem;
    margin-bottom: 8px;
}

.stat-card h3 i {
    color: var(--accent);
    margin-right: 6px;
}

.stat-card .amount {
    font-size: 1.45rem;
}

.tone-1 {
    background: linear-gradient(160deg, rgba(52, 152, 219, .28), rgba(27, 34, 48, .8));
}

.tone-2 {
    background: linear-gradient(160deg, rgba(46, 204, 113, .23), rgba(27, 34, 48, .8));
}

.tone-3 {
    background: linear-gradient(160deg, rgba(155, 89, 182, .26), rgba(27, 34, 48, .8));
}

.tone-4 {
    background: linear-gradient(160deg, rgba(241, 196, 15, .24), rgba(27, 34, 48, .8));
}

.tone-5 {
    background: linear-gradient(160deg, rgba(26, 188, 156, .24), rgba(27, 34, 48, .8));
}

.tone-6 {
    background: linear-gradient(160deg, rgba(230, 126, 34, .24), rgba(27, 34, 48, .8));
}

.tone-7 {
    background: linear-gradient(160deg, rgba(231, 76, 60, .2), rgba(27, 34, 48, .8));
}

.mobile-app-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    background: rgba(11, 16, 24, .96);
    border-top: 1px solid rgba(255, 255, 255, .14);
    display: none;
    grid-template-columns: repeat(4, 1fr);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    gap: 8px;
}

.mobile-app-nav a {
    text-decoration: none;
    color: #cfe0f4;
    font-size: .72rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 7px 4px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .04);
}

.mobile-app-nav a.active {
    color: var(--accent);
    border: 1px solid rgba(245, 166, 35, .55);
}

@media (max-width: 700px) {
    .actions {
        flex-direction: column;
    }

    .nav a {
        margin-left: 10px;
    }

    .brand-logo {
        height: 30px;
    }

    .quick-action-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}

@media (max-width: 760px) {
    .container {
        width: 96%;
    }

    .grid.two,
    .grid.three,
    .grid.four {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr)) !important;
    }

    .actions {
        gap: 8px;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        border-radius: 10px;
    }

    .topbar .row {
        align-items: center;
        gap: 8px;
    }

    .nav-desktop {
        display: none;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .brand-name {
        display: none;
    }

    .nav-avatar-link {
        margin-left: auto;
        margin-right: 8px;
    }

    .card,
    .subcard {
        padding: 14px;
        margin-bottom: 12px;
    }

    .amount {
        font-size: 1.35rem;
    }

    input,
    select,
    textarea,
    button {
        font-size: 16px;
    }

    .main.auth-page {
        align-items: center;
    }

    .auth-help {
        flex-direction: column;
        align-items: flex-start;
    }

    .quick-action-grid.compact-actions {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 7px;
    }

    .quick-action-grid.compact-actions .quick-action-card {
        padding: 8px 6px;
        border-radius: 10px;
        gap: 5px;
        align-items: center;
        text-align: center;
        min-height: 74px;
    }

    .quick-action-grid.compact-actions .quick-action-card i {
        width: 24px;
        height: 24px;
        font-size: .75rem;
        border-radius: 7px;
        margin: 0 auto;
    }

    .quick-action-grid.compact-actions .quick-action-card strong {
        font-size: .72rem;
        line-height: 1.15;
    }

    .quick-action-grid.compact-actions .quick-action-card small {
        display: none;
    }

    .mobile-app-nav {
        display: grid;
    }

    body {
        padding-bottom: 82px;
    }
}