/* ── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #0a0e17;
    --bg-card: #111827;
    --bg-card-hover: #1a2234;
    --bg-input: #1e293b;
    --bg-sidebar: #0d1321;
    --border: #1e293b;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #475569;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --green: #10b981;
    --red: #ef4444;
    --blue: #3b82f6;
    --gold: #f59e0b;
    --cyan: #06b6d4;
    --purple: #8b5cf6;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* ── Login ─────────────────────────────────────────────────── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at top, #1a1040 0%, var(--bg-dark) 60%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow), 0 0 80px rgba(139, 92, 246, 0.08);
    animation: fadeInUp 0.5s ease;
}

.login-logo {
    font-size: 56px;
    margin-bottom: 8px;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 15px;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.input-group input:focus,
.input-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent), #6d28d9);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 12px 24px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.error-text {
    color: var(--red);
    font-size: 14px;
    margin-top: 12px;
    min-height: 20px;
}

.login-hint {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 24px;
}

.login-hint code {
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--accent);
}

/* ── App Layout ───────────────────────────────────────────── */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand-icon {
    font-size: 28px;
}

.brand-text {
    font-size: 20px;
    font-weight: 800;
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    color: var(--text);
    background: rgba(139, 92, 246, 0.05);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(139, 92, 246, 0.08);
    border-left-color: var(--accent);
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.btn-logout {
    width: 100%;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    padding: 32px;
    overflow-y: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.btn-refresh {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-refresh:hover {
    background: var(--bg-card-hover);
}

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
}

.stat-purple::before {
    background: linear-gradient(90deg, var(--purple), #a78bfa);
}

.stat-blue::before {
    background: linear-gradient(90deg, var(--blue), #60a5fa);
}

.stat-green::before {
    background: linear-gradient(90deg, var(--green), #34d399);
}

.stat-gold::before {
    background: linear-gradient(90deg, var(--gold), #fbbf24);
}

.stat-cyan::before {
    background: linear-gradient(90deg, var(--cyan), #22d3ee);
}

.stat-pnl-pos::before {
    background: linear-gradient(90deg, var(--green), #34d399);
}

.stat-pnl-neg::before {
    background: linear-gradient(90deg, var(--red), #f87171);
}

.stat-icon {
    font-size: 24px;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Section Card ─────────────────────────────────────────── */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.section-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ── Recent Bets List ─────────────────────────────────────── */
.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.recent-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.recent-status.open {
    background: var(--green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.recent-status.closed {
    background: var(--gold);
}

.recent-status.won {
    background: var(--blue);
}

.recent-status.lost {
    background: var(--red);
}

.recent-desc {
    flex: 1;
    font-size: 14px;
}

.recent-stake {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ── Bets Page ────────────────────────────────────────────── */
.bets-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bet-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: border-color 0.2s;
}

.bet-card:hover {
    border-color: rgba(139, 92, 246, 0.3);
}

.bet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.bet-title {
    font-size: 16px;
    font-weight: 600;
}

.bet-id {
    color: var(--text-dim);
    font-size: 13px;
}

.bet-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bet-badge.open {
    background: rgba(16, 185, 129, 0.15);
    color: var(--green);
}

.bet-badge.closed {
    background: rgba(245, 158, 11, 0.15);
    color: var(--gold);
}

.bet-badge.won {
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue);
}

.bet-badge.lost {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}

.bet-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.bet-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.bet-entries {
    margin-top: 12px;
}

.bet-entry {
    display: flex;
    gap: 16px;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 6px;
}

.bet-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

.btn-win,
.btn-loss {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-win {
    background: rgba(16, 185, 129, 0.15);
    color: var(--green);
}

.btn-win:hover {
    background: rgba(16, 185, 129, 0.25);
}

.btn-loss {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}

.btn-loss:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* ── Data Table ───────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover td {
    background: rgba(139, 92, 246, 0.03);
}

.balance-pos {
    color: var(--green);
    font-weight: 600;
}

.balance-neg {
    color: var(--red);
    font-weight: 600;
}

.balance-zero {
    color: var(--text-muted);
    font-weight: 600;
}

.btn-danger-sm {
    padding: 6px 12px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.btn-danger-sm:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ── Staker Checkboxes ────────────────────────────────────── */
.staker-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.staker-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.staker-checkbox:hover {
    border-color: var(--accent);
}

.staker-checkbox.selected {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--accent);
}

.staker-checkbox input {
    display: none;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .btn-primary {
    width: auto;
    padding: 12px 32px;
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.toast.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.toast.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* ── Mobile Bottom Nav ─────────────────────────────────────── */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 100;
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    border-radius: 8px;
    transition: color 0.2s;
}

.mobile-nav-item span:first-child {
    font-size: 20px;
}

.mobile-nav-item.active {
    color: var(--accent);
}

.mobile-nav-item:hover {
    color: var(--text);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .mobile-nav {
        display: flex;
    }

    .main-content {
        padding: 16px;
        padding-bottom: 90px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-header .btn-primary {
        width: 100%;
        text-align: center;
    }

    .bet-meta {
        flex-wrap: wrap;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 12px;
    }

    .login-card {
        margin: 16px;
        padding: 32px 24px;
    }
}