/* ─────────────── CSS Variables ─────────────── */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2333;
    --bg-hover: #252d3f;
    --border-color: #30363d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent-blue: #58a6ff;
    --accent-blue-dark: #1f6feb;
    --accent-green: #3fb950;
    --accent-yellow: #d29922;
    --accent-orange: #db6d28;
    --accent-red: #f85149;
    --accent-purple: #bc8cff;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.6);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─────────────── Top Navigation ─────────────── */
.top-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-logo { font-size: 22px; }
.nav-brand {
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.nav-badge {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.online { background: var(--accent-green); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: var(--accent-red); }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.nav-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.nav-btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-blue-dark);
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}
.nav-btn-primary:hover {
    background: var(--accent-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.3);
}

/* ─────────────── Main Container ─────────────── */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 40px;
}

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

.page-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}
.header-time {
    font-size: 14px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ─────────────── Section Headers ─────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-icon {
    font-size: 22px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.section-title { font-size: 17px; font-weight: 700; }
.section-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.section-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 12px;
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse-dot 2s infinite;
}

/* ─────────────── Cards ─────────────── */
.statistics-section,
.timeline-section,
.contribution-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

/* ─────────────── Statistics Grid ─────────────── */
.statistics-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    text-align: center;
    transition: var(--transition);
}
.stat-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ─────────────── Timeline ─────────────── */
.timeline-body {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.chart-wrapper {
    height: 160px;
    position: relative;
}
@media (min-width: 768px) { .chart-wrapper { height: 200px; } }

.timeline-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-item-label { color: var(--text-muted); }
.stat-item-value { color: var(--text-primary); font-weight: 600; }
.stat-divider { color: var(--border-color); }

/* ─────────────── Contribution Graph ─────────────── */
.contribution-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.contribution-stats .stat-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    text-align: center;
    flex-direction: column;
    gap: 2px;
}
.contribution-stats .stat-item-value {
    font-size: 18px;
    font-weight: 700;
}
.contribution-stats .stat-item-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
}

.graph-wrapper {
    overflow-x: auto;
    padding: 4px 0;
}

.graph-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.legend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}
.legend-squares { display: flex; gap: 2px; }
.legend-square {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}
.legend-square.level-0 { background: var(--bg-tertiary); opacity: 0.3; }
.legend-square.level-1 { background: #0e4429; opacity: 0.5; }
.legend-square.level-2 { background: #1a7f3a; opacity: 0.7; }
.legend-square.level-3 { background: #2ea043; opacity: 0.85; }
.legend-square.level-4 { background: #3fb950; opacity: 1; }
.legend-square.level-5 { background: #56d364; opacity: 1; }
.legend-square.level-6 { background: #7ee787; opacity: 1; }
.legend-square.future {
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    opacity: 0.4;
}
.legend-divider { color: var(--border-color); }
.legend-future { display: flex; align-items: center; gap: 4px; }

.tooltip {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
    pointer-events: none;
    z-index: 1000;
    color: var(--text-primary);
}

.insights {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: center;
}
.insights strong { color: var(--text-primary); }

/* ─────────────── Contribution Cells ─────────────── */
.cell {
    border-radius: 3px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}
.cell:hover {
    transform: scale(1.25);
    z-index: 10;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}
.cell.level-0 { background: var(--bg-tertiary); opacity: 0.3; }
.cell.level-1 { background: #0e4429; opacity: 0.5; }
.cell.level-2 { background: #1a7f3a; opacity: 0.7; }
.cell.level-3 { background: #2ea043; opacity: 0.85; }
.cell.level-4 { background: #3fb950; opacity: 1; }
.cell.level-5 { background: #56d364; opacity: 1; }
.cell.level-6 { background: #7ee787; opacity: 1; }
.cell.future {
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    opacity: 0.4;
    cursor: not-allowed;
}
.cell.today {
    border: 2px solid var(--accent-blue);
    box-shadow: 0 0 8px rgba(88, 166, 255, 0.3);
}
.cell-placeholder { opacity: 0; }

.month-label {
    font-size: 9px;
    font-weight: 500;
    color: var(--text-secondary);
}
.day-label {
    font-size: 8px;
    color: var(--text-muted);
}

/* ─────────────── Stats Grid ─────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stats-grid .stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    text-align: left;
}
.stats-grid .stat-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-card-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}
.stat-card-content { flex: 1; }
.stat-card-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    display: block;
}
.stat-card-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.stat-card-value .unit {
    font-size: 15px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* ─────────────── Controls ─────────────── */
.select-control {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}
.select-control:hover { border-color: var(--accent-blue); }
.select-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.btn-refresh, .btn-secondary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-refresh:hover, .btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}
.btn-refresh:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-refresh .spin { animation: spin 1s linear infinite; }

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

/* ─────────────── No Data ─────────────── */
.no-data-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: var(--text-muted);
    font-size: 13px;
}
.no-data-message span:first-child { font-size: 24px; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.empty-text { font-size: 14px; }

/* ─────────────── Footer ─────────────── */
.footer {
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* ─────────────── Responsive ─────────────── */
@media (max-width: 992px) {
    .statistics-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .contribution-stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .statistics-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .contribution-stats { grid-template-columns: repeat(2, 1fr); }
    .section-header { flex-direction: column; align-items: stretch; }
    .section-header-right { justify-content: flex-start; }
    .timeline-stats { flex-direction: column; align-items: flex-start; gap: 4px; }
    .stat-divider { display: none; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .top-nav { padding: 0 16px; }
    .nav-right .status-indicator { display: none; }
    .main-container { padding: 16px; }
}

@media (max-width: 480px) {
    .statistics-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .contribution-stats { grid-template-columns: 1fr 1fr; }
    .nav-brand { display: none; }
    .nav-btn-primary span { display: none; }
    .stat-card-value { font-size: 20px; }
    .stat-value { font-size: 20px; }
    .page-title { font-size: 22px; }
}