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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --accent: #f97316;
    --bg-main: #ffffff;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --radius: 1rem;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-main);
    color: var(--text);
    line-height: 1.5;
    transition: var(--transition);
}

/* Header Styles */
header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

header p {
    opacity: 0.9;
    font-size: 0.9rem;
}

/* Mode Switch */
.mode-switch {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.mode-switch button {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Theme Panel */
.theme-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.theme-panel h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.theme-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.control-group input,
.control-group select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-main);
    color: var(--text);
    cursor: pointer;
}

.reset-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

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

.stat-card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-card .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    display: block;
}

/* Table Styles */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

thead {
    background: var(--primary);
    color: white;
}

th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

input, select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    background: var(--bg-main);
    color: var(--text);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

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

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

.btn-delete {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-delete:hover {
    opacity: 0.8;
}

.controls {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Result Container */
.result-container {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--surface-alt);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.progress-bg {
    background: var(--border);
    border-radius: 1rem;
    height: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    width: 0%;
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 1rem;
}

#result-text {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

/* Grade Legend */
.grade-legend {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.grade-legend h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.legend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-weight: 600;
    font-size: 0.7rem;
}

.badge.green { background: #10b981; color: white; }
.badge.blue { background: #3b82f6; color: white; }
.badge.yellow { background: #eab308; color: white; }
.badge.orange { background: #f97316; color: white; }
.badge.red { background: #ef4444; color: white; }
.badge.danger { background: #7f1a1a; color: white; }

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Calculator Section */
.calculator-section {
    animation: fadeIn 0.3s ease;
}

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

/* Dark Theme Support */
body.dark-theme-text {
    --text: #f1f5f9;
    --text-muted: #94a3b8;
}