:root {
    --brand-1: #4f46e5;
    --brand-2: #7c3aed;
    --brand-3: #06b6d4;
    --ink: #1e2433;
    --muted: #6b7280;
    --bg: #f4f5fb;
    --card-bg: #ffffff;
    --border: #e6e8f0;
    --good: #16a34a;
    --bad: #dc2626;
    --gold: #f59e0b;
    --silver: #94a3b8;
    --bronze: #b45309;
    --radius: 16px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    margin: 0;
    min-height: 100vh;
}

a { text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 270px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 55%, #4f46e5 100%);
    color: #e5e7ff;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    overflow-y: auto;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    font-weight: 700;
    font-size: 1.02rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
    line-height: 1.25;
}
.sidebar-brand .badge-icon {
    width: 38px; height: 38px;
    background: rgba(255,255,255,.15);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-section {
    padding: 14px 20px 6px;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .08em;
    color: rgba(229,231,255,.55);
    font-weight: 600;
}

.sidebar-nav { list-style: none; margin: 0; padding: 4px 12px 20px; }
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e5e7ff;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: .92rem;
    margin-bottom: 3px;
    transition: background .15s ease, transform .1s ease;
}
.sidebar-nav li a i { width: 18px; text-align: center; opacity: .85; }
.sidebar-nav li a:hover { background: rgba(255,255,255,.12); }
.sidebar-nav li a.active { background: rgba(255,255,255,.18); font-weight: 600; }
.sidebar-nav .sub { padding-left: 16px; }
.sidebar-nav .sub a { font-size: .86rem; opacity: .92; }

.main {
    margin-left: 270px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar h1 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: var(--ink);
}
.topbar .subtitle { font-size: .8rem; color: var(--muted); margin-top: 2px; }

.content { padding: 28px; max-width: 1180px; width: 100%; margin: 0 auto; }

.sidebar-toggle { display: none; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
}

/* ---------- Cards ---------- */
.card-modern {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 22px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}

.hero {
    border-radius: 20px;
    padding: 34px 32px;
    background: linear-gradient(120deg, var(--brand-1), var(--brand-2) 60%, var(--brand-3));
    color: #fff;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.hero h2 { font-weight: 700; font-size: 1.5rem; margin: 0 0 8px; }
.hero p { opacity: .92; max-width: 620px; margin: 0; font-size: .92rem; }
.hero .hero-badge {
    display: inline-block;
    background: rgba(255,255,255,.18);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: 12px;
    font-weight: 600;
}

.pill { display:inline-flex; align-items:center; gap:5px; padding: 3px 11px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.pill-benefit { background: #dcfce7; color: var(--good); }
.pill-cost { background: #fee2e2; color: var(--bad); }

/* ---------- Step accordion ---------- */
.step {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    background: var(--card-bg);
}
.step-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    background: #fafaff;
}
.step-head:hover { background: #f2f2ff; }
.step-num {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
    color: #fff;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: .92rem;
}
.step-title { font-weight: 600; font-size: .96rem; flex: 1; }
.step-sub { font-size: .78rem; color: var(--muted); margin-top: 1px; }
.step-chevron { color: var(--muted); transition: transform .2s ease; }
.step.open .step-chevron { transform: rotate(180deg); }
.step-body { padding: 20px; border-top: 1px solid var(--border); display: none; }
.step.open .step-body { display: block; }

.formula-box {
    background: #f8f8ff;
    border: 1px dashed #c7c9f5;
    border-radius: 12px;
    padding: 14px 18px;
    margin: 10px 0 16px;
    font-size: .95rem;
    overflow-x: auto;
}

.calc-line {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: .92rem;
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
}
.calc-line:last-child { border-bottom: none; }

/* fraction helper (kept from legacy app, restyled) */
.All { display: table-row; }
.Sum { display: table-cell; vertical-align: middle; padding: 2px 4px; }
.Fraction { display: table-cell; text-align: center; }
.Denominator { border-top: 1.5px solid var(--ink); display: block; padding-top: 1px; }
.Fraction, .Numerator, .Denominator { padding: 0 6px; }

/* ---------- Tables ---------- */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .88rem;
}
.table-modern th {
    background: #f1f1fb;
    color: #40407a;
    font-weight: 600;
    padding: 10px 12px;
    text-align: center;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table-modern td {
    padding: 9px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.table-modern tbody tr:hover { background: #fafaff; }
.table-modern td.label, .table-modern th.label { text-align: left; }
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.table-wrap .table-modern { border: none; }

.badge-best { background: linear-gradient(135deg,#fbbf24,#f59e0b); color:#fff; padding:2px 10px; border-radius:999px; font-size:.7rem; font-weight:700; }

/* ---------- Ranking / podium ---------- */
.podium { display: flex; align-items: flex-end; gap: 14px; justify-content: center; margin: 26px 0 10px; flex-wrap: wrap; }
.podium-item { text-align: center; width: 150px; }
.podium-card {
    border-radius: 14px 14px 0 0;
    padding: 16px 10px 10px;
    color: #fff;
    font-weight: 700;
}
.podium-1 .podium-card { background: linear-gradient(160deg,#fde68a,var(--gold)); height: 130px; }
.podium-2 .podium-card { background: linear-gradient(160deg,#e2e8f0,var(--silver)); height: 100px; }
.podium-3 .podium-card { background: linear-gradient(160deg,#fcd9b6,var(--bronze)); height: 76px; }
.podium-medal { font-size: 1.6rem; margin-bottom: 4px; }
.podium-name { font-size: .82rem; margin-top: 8px; font-weight: 600; color: var(--ink); }
.podium-score { font-size: .78rem; color: var(--muted); }

.rank-row-1 { background: linear-gradient(90deg, #fffbea, transparent); font-weight: 700; }

/* ---------- Buttons ---------- */
.btn-brand {
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    border: none;
    color: #fff;
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .9rem;
}
.btn-brand:hover { opacity: .92; color: #fff; }

/* form */
.form-modern label { font-size: .85rem; font-weight: 600; color: var(--ink); margin-bottom: 4px; display: block; }
.form-modern .form-control, .form-modern .form-select {
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 9px 12px;
    font-size: .9rem;
}
.form-modern .form-control:focus, .form-modern .form-select:focus {
    border-color: var(--brand-1);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.section-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 4px 0 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title i { color: var(--brand-1); }

.muted { color: var(--muted); }
.small-note { font-size: .78rem; color: var(--muted); }
