:root {
    --bg-primary: #0a0c14;
    --bg-secondary: #111420;
    --bg-card: #161a26;
    --bg-card-hover: #1c2131;
    --bg-input: #0d0f18;
    --border: #1e2333;
    --border-light: #293045;
    --text-primary: #e4e7f0;
    --text-secondary: #8a8fa8;
    --text-muted: #585d74;
    --accent: #00d69f;
    --accent-glow: rgba(0, 214, 159, 0.15);
    --accent-dim: #0a7a5e;
    --profit: #00d69f;
    --profit-bg: rgba(0, 214, 159, 0.08);
    --loss: #ff4f6e;
    --loss-bg: rgba(255, 79, 110, 0.08);
    --warning: #f0a040;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 2px 16px rgba(0,0,0,0.3);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(0, 214, 159, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 214, 159, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* HEADER */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(17, 20, 32, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #008060);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #0a0c14;
}

.logo-text {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
}

.logo-text span {
    color: var(--accent);
}

.nav {
    display: flex;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 4px;
    gap: 2px;
}

.nav-btn {
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    white-space: nowrap;
}

.nav-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.nav-btn.active { color: #0a0c14; background: var(--accent); font-weight: 600; }
.nav-btn.active:hover { background: var(--accent); }

/* CONTAINER */
.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 32px 24px;
    position: relative;
    z-index: 1;
}

/* PAGES */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }

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

/* CARDS */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
    font-weight: 700;
}

.card-body { padding: 24px; }
.card-body.no-pad { padding: 0; }

/* STAT ROW */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    text-align: center;
    transition: all var(--transition);
}

.stat-item:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-value.profit { color: var(--profit); }
.stat-value.loss { color: var(--loss); }

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 4px;
    font-weight: 600;
}

/* TABLE */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: var(--bg-secondary);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(30, 35, 51, 0.6);
    transition: background var(--transition);
}

tbody tr:hover td { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }

.rank-cell {
    width: 48px;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.rank-medal {
    font-size: 1.1rem;
}

.player-link {
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.profit-cell { font-weight: 700; }
.profit-cell.pos { color: var(--profit); }
.profit-cell.neg { color: var(--loss); }
.profit-cell.zero { color: var(--text-muted); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.badge-up { background: var(--profit-bg); color: var(--profit); }
.badge-down { background: var(--loss-bg); color: var(--loss); }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #0a0c14;
}

.btn-primary:hover {
    background: #00e8ae;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-danger {
    background: rgba(255,79,110,0.12);
    color: var(--loss);
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-danger:hover { background: rgba(255,79,110,0.25); }

.btn-sm { padding: 6px 14px; font-size: 0.78rem; }

/* FORMS */
.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.form-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.form-row > *:first-child { flex: 1; }

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
}

input, select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}

input:hover { border-color: var(--border-light); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

input[type="date"] {
    color-scheme: dark;
    max-width: 200px;
}

input[type="number"] { max-width: 80px; text-align: center; }

/* SESSION PLAYERS */
.players-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.players-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 40px;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.players-header span:last-child { text-align: center; }

.player-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 40px;
    gap: 8px;
    padding: 8px 16px;
    align-items: center;
    border-bottom: 1px solid rgba(30,35,51,0.4);
    transition: background var(--transition);
}

.player-row:last-child { border-bottom: none; }
.player-row:hover { background: var(--bg-card-hover); }

.player-row .player-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.player-row input {
    padding: 8px 6px;
    max-width: 100%;
    font-size: 0.85rem;
}

.remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all var(--transition);
}

.remove-btn:hover {
    color: var(--loss);
    background: var(--loss-bg);
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.empty-state p { font-size: 0.9rem; }

/* CHARTS */
.chart-wrap {
    position: relative;
    width: 100%;
    height: 320px;
    margin: 8px 0 24px;
}

/* BACK LINK */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color var(--transition);
    padding: 6px 0;
}

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

/* SESSION DETAIL */
.session-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.session-meta .chip {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.session-meta .chip strong {
    color: var(--text-primary);
}

/* ACTIONS ROW */
.actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 20px;
    gap: 8px;
}

/* TOTALS CARD */
.totals-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.total-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    text-align: center;
    border: 1px solid var(--border);
}

.total-item .value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.total-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 4px;
    font-weight: 600;
}

/* SECTION TITLE */
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* CHARTS GRID */
.grid-2-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* SINGLE-COLUMN CHART CARDS */
.chart-card {
    margin-bottom: 28px;
}
.chart-card:last-child {
    margin-bottom: 0;
}

/* MODE TOGGLE BUTTONS */
.mode-btn {
    background: transparent;
    border: none;
    color: #585d74;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.mode-btn.active {
    background: #00d69f;
    color: #0b0d17;
}
.mode-btn:hover:not(.active) {
    color: #8a8fa8;
}

/* FULLSCREEN */
.chart-wrap:fullscreen,
.chart-wrap:-webkit-full-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b0d17;
    padding: 40px;
    width: 100%;
    height: 100%;
}
.chart-wrap:fullscreen canvas,
.chart-wrap:-webkit-full-screen canvas {
    max-height: 90vh;
    max-width: 95vw;
    width: 100% !important;
    height: auto !important;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .header {
        padding: 0 16px;
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 10px;
    }

    .nav {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .nav-btn {
        padding: 8px 14px;
        font-size: 0.78rem;
    }

    .container { padding: 20px 12px; }

    .players-header,
    .player-row {
        grid-template-columns: 1.5fr 1fr 1fr 1fr 30px;
        gap: 4px;
    }

    .player-row input { font-size: 0.8rem; }

    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .totals-card { grid-template-columns: repeat(2, 1fr); }
    .grid-2-charts { grid-template-columns: 1fr; }
}
