@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css");

:root {
    --bg-main: #0f172a;
    --bg-card: #111827;
    --text-primary: #e5e7eb;
    --text-muted: #94a3b8;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-blue: #38bdf8;
    --border-soft: #1f2937;
    --radius-lg: 14px;
    --shadow-soft: 0 14px 30px rgba(2, 6, 23, 0.28);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    background: var(--bg-main);
    color: var(--text-primary);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}

a {
    color: var(--accent-blue);
}

.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: rgba(17, 24, 39, 0.96);
    border-right: 1px solid var(--border-soft);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    z-index: 40;
}

.sidebar h2 {
    margin: 4px 10px 18px;
    color: #f8fafc;
    letter-spacing: 0.3px;
    font-size: 1.15rem;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar a:hover {
    color: #f8fafc;
    background: rgba(56, 189, 248, 0.12);
    transform: translateX(2px);
}

.sidebar a.active {
    color: #f8fafc;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.16), rgba(34, 197, 94, 0.16));
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.sidebar a::before {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    width: 16px;
    text-align: center;
    opacity: 0.85;
}

.sidebar a.has-inline-icon::before {
    content: none !important;
}

.sidebar a.has-inline-icon i {
    width: 16px;
    text-align: center;
    opacity: 0.9;
}

.sidebar a[href*="dashboard"]::before { content: "\f624"; }
.sidebar a[href*="profile"]::before { content: "\f007"; }
.sidebar a[href*="accounting"]::before { content: "\f53a"; }
.sidebar a[href*="challenges"]::before { content: "\f0c0"; }
.sidebar a[href*="leagues"]::before { content: "\f500"; }
.sidebar a.icon-leagues-index::before { content: "\f500"; }
.sidebar a.icon-create-league::before { content: "\2b"; }
.sidebar a.icon-join-league::before { content: "\f090"; }
.sidebar a.icon-challenges::before { content: "\f0c0"; }
.sidebar a.icon-leaderboard::before { content: "\f201"; }
.sidebar a.icon-gameweeks::before { content: "\f073"; }
.sidebar a[href*="deposit"]::before { content: "\f555"; }
.sidebar a[href*="withdraw"]::before { content: "\f3d1"; }
.sidebar a[href*="history"]::before,
.sidebar a[href*="transactions"]::before { content: "\f570"; }
.sidebar a[href*="results"]::before { content: "\f46c"; }
.sidebar a[href*="payout_logs"]::before { content: "\f571"; }
.sidebar a[href*="lock"]::before { content: "\f023"; }
.sidebar a[href*="settle"]::before { content: "\f0e3"; }
.sidebar a[href*="logout"]::before { content: "\f2f5"; }

.main {
    margin-left: 260px;
    width: calc(100% - 260px);
    padding: 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
}

.topbar h1 {
    font-size: 1.45rem;
    line-height: 1.2;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wallet-topup {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(56, 189, 248, 0.45);
    background: rgba(14, 165, 233, 0.18);
    color: #e0f2fe;
    text-decoration: none;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.wallet-topup:hover {
    background: rgba(14, 165, 233, 0.28);
    border-color: rgba(56, 189, 248, 0.8);
    transform: translateY(-1px);
}

.topbar .pill,
.topbar > div:last-child {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #f8fafc;
    background: linear-gradient(135deg, #0891b2, #22c55e);
}

.menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-primary);
    padding: 0;
}

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

.card {
    background: linear-gradient(165deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: scale(1.01);
    box-shadow: 0 18px 34px rgba(2, 6, 23, 0.35);
}

.card h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.card p {
    font-size: 0.98rem;
}

.cards .card p {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--accent-blue);
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #334155;
    background: rgba(15, 23, 42, 0.95);
    color: #f8fafc;
    font-size: 0.95rem;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(56, 189, 248, 0.65);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
}

button,
.btn-primary {
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    color: #fff;
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.25);
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.9);
    color: var(--text-primary);
    border-color: #334155;
}

.btn-success {
    background: linear-gradient(135deg, #15803d, #22c55e);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, #b45309, #f59e0b);
    color: #fff;
}

button:disabled,
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn.is-loading::after,
button.is-loading::after {
    content: "";
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow: hidden;
}

.table th,
.table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: top;
}

.table tr:last-child td {
    border-bottom: 0;
}

.table th {
    color: #bae6fd;
    font-size: 0.8rem;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: rgba(15, 23, 42, 0.85);
}

.table tbody tr:nth-child(even),
.table tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.48);
}

.table tr:hover td {
    background: rgba(56, 189, 248, 0.08);
}

.amount {
    text-align: right;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    border: 1px solid;
}

.badge::before {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.badge-pending {
    background: rgba(180, 83, 9, 0.2);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.45);
}

.badge-pending::before { content: "\f017"; }

.badge-confirmed,
.badge-approved,
.badge-paid {
    background: rgba(21, 128, 61, 0.2);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.45);
}

.badge-confirmed::before,
.badge-approved::before,
.badge-paid::before { content: "\f00c"; }

.badge-failed,
.badge-rejected {
    background: rgba(153, 27, 27, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.45);
}

.badge-failed::before,
.badge-rejected::before { content: "\f00d"; }

.badge-locked {
    background: rgba(30, 64, 175, 0.22);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.45);
}

.badge-open {
    background: rgba(2, 132, 199, 0.22);
    color: #7dd3fc;
    border-color: rgba(56, 189, 248, 0.45);
}

.badge-settled {
    background: rgba(21, 128, 61, 0.2);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.45);
}

.flash {
    border: 1px solid var(--border-soft);
    border-left-width: 4px;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    animation: fadeIn 0.28s ease;
}

.flash-success {
    border-left-color: var(--accent-green);
    color: #86efac;
    background: rgba(22, 101, 52, 0.15);
}

.flash-error {
    border-left-color: var(--accent-red);
    color: #fca5a5;
    background: rgba(127, 29, 29, 0.2);
}

.flash-warning {
    border-left-color: var(--accent-yellow);
    color: #fde68a;
    background: rgba(146, 64, 14, 0.2);
}

.empty-state {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 1.4rem;
    color: var(--accent-yellow);
    margin-bottom: 8px;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    align-items: end;
}

.inline-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border-radius: 10px;
    text-decoration: none;
    border: 1px solid #334155;
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.9);
    font-size: 0.86rem;
}

.quick-link.active {
    background: rgba(37, 99, 235, 0.25);
    color: #bfdbfe;
    border-color: rgba(59, 130, 246, 0.45);
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.pagination .links {
    display: flex;
    gap: 10px;
}

.muted {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 14px;
}

.auth-container {
    width: min(420px, 100%);
    background: linear-gradient(165deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.95));
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    padding: 28px;
    box-shadow: var(--shadow-soft);
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 18px;
    font-size: 1.4rem;
}

.auth-container p {
    text-align: center;
}

.auth-links {
    margin-top: 12px;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.league-toolbar {
    display: grid;
    grid-template-columns: 1.4fr repeat(3, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.league-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.league-card {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.league-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.league-card-title {
    margin: 0;
    font-size: 1.03rem;
    color: #f8fafc;
}

.league-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: rgba(15, 23, 42, 0.9);
    color: #cbd5e1;
    font-size: 0.75rem;
    font-weight: 600;
}

.league-card-desc {
    color: var(--text-muted);
    font-size: 0.88rem;
    min-height: 42px;
}

.league-card-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gw-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
}

.gw-next-card {
    min-height: 210px;
}

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

.countdown-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.countdown-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.45);
    background: rgba(146, 64, 14, 0.2);
    color: #fde68a;
    font-size: 0.8rem;
    font-weight: 700;
}

.progress-line {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid #334155;
    overflow: hidden;
}

.progress-line > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f59e0b, #22c55e);
    transition: width .5s ease;
}

.status-wrap {
    max-width: 680px;
    margin: 24px auto;
    text-align: center;
}

.spinner {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 6px solid rgba(56, 189, 248, 0.2);
    border-top-color: var(--accent-blue);
    margin: 20px auto;
    animation: spin 1s linear infinite;
}

.status-text {
    font-size: 1.08rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.status-subtext {
    color: var(--text-muted);
    font-size: 0.92rem;
}

.status-ok {
    color: #86efac;
}

.status-bad {
    color: #fca5a5;
}

.status-muted {
    color: #fde68a;
}

.hide {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1024px) {
    .main {
        padding: 18px;
    }

    .gw-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .menu-toggle {
        display: inline-flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

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

    .league-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1120px) and (min-width: 861px) {
    .league-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
