:root {
    --primary: #1a6b3c;
    --primary-light: #2e8b57;
    --primary-dark: #0d4f2b;
    --accent: #f4a100;
    --accent-light: #ffc107;
    --bg: #f0f4f0;
    --card: #ffffff;
    --text: #2c3e2c;
    --text-light: #5a6b5a;
    --border: #d4e4d4;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --radius: 12px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
}

/* SIDEBAR */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 20px 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 10px 20px 25px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    margin-bottom: 10px;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.4;
}

.sidebar-header .badge {
    display: inline-block;
    background: var(--accent);
    color: var(--primary-dark);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 8px;
}

.nav-section {
    padding: 8px 15px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.5);
    margin-top: 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--accent);
}

.nav-item .icon { font-size: 1.1rem; width: 24px; text-align: center; }

.nav-sub {
    padding-left: 54px;
    font-size: 0.8rem;
    padding-top: 7px;
    padding-bottom: 7px;
    color: rgba(255,255,255,0.6);
}

.nav-sub:hover, .nav-sub.active {
    color: var(--accent-light);
    background: rgba(255,255,255,0.05);
}

/* MAIN */
.main {
    margin-left: 280px;
    min-height: 100vh;
}

.topbar {
    background: white;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary);
}

.topbar h1 {
    font-size: 1rem;
    color: var(--primary);
}

.content {
    padding: 30px;
    max-width: 1100px;
    margin: 0 auto;
}

/* SECTIONS */
.section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.section.active { display: block; }

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

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card h4 {
    color: var(--primary-light);
    margin: 18px 0 10px;
    font-size: 1rem;
}

.card p, .card li {
    color: var(--text-light);
    font-size: 0.92rem;
    margin-bottom: 8px;
}

.card ul, .card ol {
    padding-left: 20px;
}

.highlight-box {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    border-left: 4px solid var(--primary);
    padding: 18px 22px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 15px 0;
}

.formula-box {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 18px;
    margin: 12px 0;
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: 1.05rem;
    text-align: center;
    color: #333;
    overflow-x: auto;
}

.formula-box .katex-display {
    margin: 0;
}

.formula-box .label {
    font-family: 'Segoe UI', sans-serif;
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 6px;
}

/* NOTE BOX */
.note-box {
    background: #f5f5f5;
    border: 1px dashed #bdbdbd;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 12px 0;
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.6;
}

.note-box ul {
    padding-left: 18px;
    margin-bottom: 0;
}

.note-box li {
    margin-bottom: 4px;
}

/* ANALOGY & STEP BOXES */
.analogy-box {
    background: linear-gradient(135deg, #fff8e1, #fff3e0);
    border-left: 4px solid var(--accent);
    padding: 16px 20px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 12px 0;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.6;
}

.step-box {
    background: linear-gradient(135deg, #e3f2fd, #e8eaf6);
    border-left: 4px solid #2196f3;
    padding: 16px 20px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 12px 0;
    font-size: 0.9rem;
    color: var(--text);
}

.step-box ol {
    padding-left: 20px;
    margin-top: 8px;
}

.step-box li {
    margin-bottom: 6px;
}

.step-box code, .analogy-box code {
    background: rgba(0,0,0,0.07);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.88rem;
}

/* STEM BADGES */
.stem-badges {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 15px 0;
}

.stem-badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    color: white;
}

.stem-badge.science { background: #2196f3; }
.stem-badge.tech { background: #4caf50; }
.stem-badge.eng { background: #ff9800; }
.stem-badge.math { background: #9c27b0; }
.stem-badge.econ { background: #e91e63; }

/* FORM / SIMULATOR */
.sim-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.form-group input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

.range-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-light);
}

.range-value {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

.btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(26,107,60,0.3);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: var(--primary-dark);
}

/* RESULTS */
.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.result-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 18px;
    border-radius: var(--radius);
    text-align: center;
}

.result-card .value {
    font-size: 1.6rem;
    font-weight: 800;
}

.result-card .label {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 4px;
}

.result-card.accent {
    background: linear-gradient(135deg, var(--accent), #e6950a);
}

.result-card.info {
    background: linear-gradient(135deg, #2196f3, #42a5f5);
}

.result-card.purple {
    background: linear-gradient(135deg, #7b1fa2, #9c27b0);
}

/* CHART */
.chart-container {
    position: relative;
    height: 350px;
    margin: 15px 0;
}

/* TABS */
.tab-nav {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* 5E STEPS */
.step-progress {
    display: flex;
    justify-content: space-between;
    margin: 20px 0 30px;
    position: relative;
}

.step-progress::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 40px;
    right: 40px;
    height: 3px;
    background: var(--border);
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 1;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-light);
    transition: all 0.3s;
}

.step-item.active .step-circle {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.step-item.completed .step-circle {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.step-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-light);
}

.step-item.active .step-label { color: var(--primary); }

.step-panel { display: none; }
.step-panel.active { display: block; }

/* TABLE */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 10px 0;
}

th {
    background: var(--primary);
    color: white;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
}

tr:hover td { background: #f5f9f5; }

/* GAUGE */
.gauge-wrap {
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.gauge-container {
    width: 200px;
    height: 120px;
    position: relative;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburger { display: block; }
    .sim-grid { grid-template-columns: 1fr; }
    .result-grid { grid-template-columns: 1fr 1fr; }
    .step-progress { flex-wrap: wrap; gap: 10px; justify-content: center; }
    .step-progress::before { display: none; }
    .content { padding: 20px 15px; }
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

.overlay.open { display: block; }

/* Scroll smooth */
html { scroll-behavior: smooth; }

/* Lifecycle diagram */
.lifecycle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 15px 0;
}

.lifecycle-item {
    text-align: center;
    padding: 15px 10px;
    background: #f5f9f5;
    border-radius: 10px;
    border: 2px solid var(--border);
}

.lifecycle-item .emoji { font-size: 2rem; }
.lifecycle-item .name { font-weight: 700; font-size: 0.85rem; margin: 5px 0 3px; }
.lifecycle-item .desc { font-size: 0.72rem; color: var(--text-light); }

.arrow-right::after {
    content: '→';
    position: absolute;
    right: -15px;
    top: 50%;
    font-size: 1.2rem;
    color: var(--primary);
}

/* Print */
@media print {
    .sidebar, .topbar, .hamburger { display: none !important; }
    .main { margin-left: 0; }
    .section { display: block !important; page-break-inside: avoid; }
}
