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

:root {
    --bg: #0B1410;
    --surface: #131F1A;
    --surface-2: #182620;
    --border: #223028;
    --accent: #34D399;
    --accent-dim: #1F5C43;
    --gold: #E8B34C;
    --text: #EAF2ED;
    --muted: #8FA396;
    --error: #F87171;
    --error-dim: #3A1E1E;
    --success-dim: #16332A;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Space Grotesk', 'Inter', sans-serif; margin: 0 0 4px; }
p { margin: 0 0 8px; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); font-size: 14px; }
.optional { color: var(--muted); font-weight: 400; font-size: 13px; }

/* ---------------- Auth pages ---------------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.auth-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--accent);
    margin-bottom: 20px;
}

.auth-card h1 { font-size: 24px; }
.auth-sub { color: var(--muted); margin-bottom: 20px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 14px; color: var(--muted); }
.admin-link { margin-top: 6px; }

form label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 14px;
}

input, select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ---------------- Buttons ---------------- */
.btn-primary, .btn-secondary, .btn-small {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    transition: transform 0.08s ease;
}
.btn-primary:active, .btn-secondary:active, .btn-small:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: #06140D;
    padding: 12px 20px;
    font-size: 15px;
}
.btn-primary:hover { background: #3EE0A8; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-lg { padding: 16px 32px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 11px 16px;
    font-size: 14px;
}

.btn-small {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 13px;
}
.btn-success { background: var(--success-dim); border-color: var(--accent-dim); color: var(--accent); }
.btn-danger { background: var(--error-dim); border-color: #5A2A2A; color: var(--error); }

/* ---------------- Alerts ---------------- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert p:last-child { margin-bottom: 0; }
.alert-error { background: var(--error-dim); color: #FCA5A5; border: 1px solid #5A2A2A; }
.alert-success { background: var(--success-dim); color: var(--accent); border: 1px solid var(--accent-dim); }

/* ---------------- App shell / sidebar ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 28px;
    padding: 0 8px;
}

.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
}
.sidebar-toggle span { display: block; width: 16px; height: 2px; background: var(--text); margin: 0 auto; border-radius: 2px; }
.sidebar-nav-logout-mobile { display: none; }

.sidebar-nav { list-style: none; margin: 0; padding: 0; flex: 1; }
.sidebar-nav li { margin-bottom: 4px; }
.sidebar-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar-nav a.active { background: var(--accent-dim); color: var(--accent); }

.sidebar-logout {
    padding: 10px 12px;
    color: var(--muted);
    font-size: 14px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.sidebar-logout:hover { color: var(--error); }

.content { flex: 1; padding: 32px 40px; max-width: 980px; }
.content-narrow { max-width: 480px; }
.content-header { margin-bottom: 28px; }
.content-header h1 { font-size: 26px; }

/* ---------------- Earning hero ---------------- */
.earn-hero {
    background: linear-gradient(160deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px;
    text-align: center;
    margin-bottom: 28px;
}

.earn-hero-label { color: var(--muted); font-size: 14px; margin-bottom: 6px; }

.earn-hero-amount {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 52px;
    color: var(--accent);
    margin-bottom: 18px;
}
.earn-hero-amount span:first-child { font-size: 30px; color: var(--gold); margin-right: 4px; }

.progress-track {
    height: 8px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}
.progress-fill { height: 100%; background: var(--accent); transition: width 1s linear; }
.earn-hero-timer { color: var(--muted); font-size: 14px; }
.earn-hero-timer strong { color: var(--text); }
#cycle-complete-msg { margin-top: 16px; }

/* ---------------- Wallet cards ---------------- */
.wallet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.wallet-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}
.wallet-card-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.wallet-card-amount { font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 600; }
.wallet-card-hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---------------- Referral box ---------------- */
.referral-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}
.referral-link-row { display: flex; gap: 8px; margin-top: 12px; }
.referral-link-row input { margin: 0; }

/* ---------------- Tables ---------------- */
.table-section { margin-bottom: 28px; }
.table-section h2 { font-size: 17px; margin-bottom: 12px; }

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: var(--success-dim); color: var(--accent); }
.badge-pending { background: #3A2F14; color: var(--gold); }
.badge-error { background: var(--error-dim); color: var(--error); }

/* ---------------- Forms / withdraw ---------------- */
.card-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}
.method-fields { margin-top: -4px; margin-bottom: 6px; }
.fee-hint { color: var(--gold); font-size: 13px; min-height: 18px; margin: -8px 0 14px; }

/* ---------------- Admin ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 22px; font-weight: 600; }

.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a { padding: 6px 12px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pagination a.active { color: var(--accent); border-color: var(--accent-dim); }

.withdrawal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.withdrawal-card-main { flex: 1; min-width: 240px; }
.withdrawal-amounts { margin: 6px 0; font-weight: 600; }
.payment-details {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    margin-top: 10px;
    white-space: pre-wrap;
    font-family: inherit;
}
.withdrawal-actions { display: flex; flex-direction: column; gap: 8px; min-width: 220px; }
.withdrawal-buttons { display: flex; gap: 8px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px;
        position: relative;
        z-index: 20;
    }
    .sidebar-top { width: 100%; }
    .sidebar-brand { margin-bottom: 0; }
    .sidebar-toggle { display: flex; }
    .sidebar-nav {
        display: none;
        flex-direction: column;
        margin-top: 12px;
        border-top: 1px solid var(--border);
        padding-top: 12px;
    }
    .sidebar-nav.open { display: flex; }
    .sidebar-nav-logout-mobile { display: block; }
    .sidebar-nav-logout-mobile a { color: var(--error); }
    .sidebar-logout { display: none; }
    .content { padding: 20px; }
    .earn-hero-amount { font-size: 38px; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    .progress-fill { transition: none; }
}
