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

:root {
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: #ffffff;
    --text: #333333;
    --muted: #666666;
    --primary: #667eea;
    --primary-600: #5a6fd8;
    --danger: #e74c3c;
    --danger-700: #c0392b;
    --axis-line: #dddddd;
    --shadow: 0 10px 30px rgba(0,0,0,0.2);
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #111827 100%);
    --card-bg: #111827;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --primary: #8b9cff;
    --primary-600: #7c8de0;
    --danger: #f87171;
    --danger-700: #ef4444;
    --axis-line: #2d3748;
    --shadow: 0 10px 30px rgba(0,0,0,0.5);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text);
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Login Page */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container h1 {
    color: white;
    margin-bottom: 30px;
    font-size: 2.5rem;
}

#login-form {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 300px;
}

#login-form input {
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

#login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

#login-form button {
    padding: 15px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

#login-form button:hover {
    background: var(--primary-600);
}

.show-password {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}

/* Profile Page */
.profile-header {
    background: var(--card-bg);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.user-info h1 {
    color: var(--text);
    font-size: 1.8rem;
}

.user-info p {
    color: var(--muted);
    margin-top: 5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

#logout-btn {
    padding: 10px 20px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

#logout-btn:hover {
    background: var(--danger-700);
}

.profile-content {
    flex: 1;
    padding: 30px;
}

.section-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.section-card h2 {
    margin-bottom: 15px;
    color: var(--text);
}

.list {
    list-style: none;
    display: grid;
    gap: 12px;
}

.list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--axis-line);
    border-radius: 8px;
}

.list .group-title {
    display: block;
    font-weight: 700;
    color: var(--text);
    margin-top: 8px;
    margin-bottom: 4px;
}

.item-title {
    color: var(--text);
    font-weight: 600;
}

.item-meta {
    color: var(--muted);
    font-size: 14px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.result-item {
    background: transparent;
    border: 1px solid var(--axis-line);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
}

.result-item .label {
    color: var(--muted);
}

.result-item .value {
    color: var(--text);
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3 {
    color: #666;
    margin-bottom: 10px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.chart-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.chart-card h3 {
    margin-bottom: 20px;
    color: var(--text);
    text-align: center;
}

/* SVG Styles */
svg {
    display: block;
    margin: 0 auto;
    width: 100%;
    height: auto;
}

.line-path {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 2s ease-in-out forwards;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

.bar {
    fill: var(--primary);
    transition: fill 0.3s;
}

.bar:hover {
    fill: var(--primary-600);
}

.pie-slice {
    transition: transform 0.3s;
    transform-origin: center;
}

.pie-slice:hover {
    transform: scale(1.05);
}

.axis-line {
    stroke: var(--axis-line);
    stroke-width: 1;
}

.axis-text {
    font-size: 12px;
    fill: var(--muted);
}

.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
}

/* Loading and Error States */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    padding: 20px 40px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    font-size: 18px;
    color: var(--text);
}

.error {
    color: var(--danger);
    text-align: center;
    margin-top: 10px;
    font-weight: 500;
}

/* Theme toggle */
#theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    z-index: 1001;
}

#theme-toggle:hover {
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .chart-card svg {
        width: 100%;
        height: auto;
    }
}