:root{
  --bg:#f8fafc;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --line:rgba(15,23,42,.10);

  --brand:#6366f1;
  --brand2:#22c55e;

  --badBg:#fee2e2;
  --badText:#991b1b;

  --goodBg:#dcfce7;
  --goodText:#166534;

  --chipBg:rgba(99,102,241,.12);
  --chipText:#3730a3;
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:var(--bg);
  color:var(--text);
}

header{
  padding:24px;
  background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(34,197,94,.12));
  border-bottom:1px solid var(--line);
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 12px;
  border-radius:999px;
  background:rgba(99,102,241,.14);
  color:#3730a3;
  font-weight:700;
  margin-bottom:10px;
}

h1{ margin:0 0 6px; font-size:28px; }
.lead{ margin:0; color:var(--muted); max-width:850px; }

.wrap{
  max-width:1100px;
  margin:0 auto;
  padding:24px;
}

.grid{
  display:grid;
  grid-template-columns: 1fr 1.2fr;
  gap:18px;
}

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

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
  padding:18px;
  box-shadow: 0 14px 32px rgba(15,23,42,.08);
}

.topic{
  display:flex;
  gap:12px;
  align-items:flex-start;
}

.icon{
  width:40px;
  height:40px;
  border-radius:12px;
  display:grid;
  place-items:center;
  background:rgba(99,102,241,.12);
  font-size:18px;
}

.controls{ margin-top:14px; }

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:10px 0;
}

.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  background:var(--chipBg);
  color:var(--chipText);
  font-weight:700;
  font-size:13px;
}

.select{
  width:100%;
  max-width: 280px;
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
  background:#fff;
  font-weight:600;
}

.meter{
  height:12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#fff;
  overflow:hidden;
}

.meterFill{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  border-radius:999px;
  transition: width .25s ease;
}

.status{
  margin-top:12px;
  padding:12px;
  border-radius:14px;
  border:1px solid var(--line);
}

.statusTitle{ font-weight:900; font-size:16px; }
.statusSub{ color:var(--muted); margin-top:4px; font-size:13px; }

.status.bad{ background:var(--badBg); color:var(--badText); border-color:rgba(153,27,27,.18); }
.status.good{ background:var(--goodBg); color:var(--goodText); border-color:rgba(22,101,52,.18); }

.btnRow{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}

.btn{
  border:none;
  border-radius:12px;
  padding:10px 14px;
  font-weight:800;
  cursor:pointer;
  background:var(--brand);
  color:white;
  box-shadow: 0 10px 18px rgba(99,102,241,.18);
}

.btn:active{ transform: translateY(1px); }

.btn.ghost{
  background:#fff;
  color:#1f2937;
  border:1px solid var(--line);
  box-shadow:none;
}

.note{
  margin-top:12px;
  font-size:13px;
  color:var(--muted);
  line-height:1.45;
  border-top:1px dashed var(--line);
  padding-top:12px;
}

.simCard{ padding:18px; }

.simTop{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:10px;
  margin-bottom:12px;
}

.simTitle{ font-weight:900; font-size:16px; }
.miniHelp{ color:var(--muted); font-size:13px; }

.equationArea{
  border:1px dashed var(--line);
  border-radius:16px;
  padding:14px;
  background: rgba(2,6,23,.02);
}

.eqLine{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:center;
  gap:10px;
  font-size:22px;
  font-weight:800;
}

.plus, .arrow{ color:var(--muted); font-weight:900; }

.term{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
}

.coeff{
  width:54px;
  border:1px solid var(--line);
  border-radius:12px;
  padding:8px 10px;
  font-size:16px;
  font-weight:900;
  text-align:center;
  outline:none;
}

.formula{ letter-spacing:.2px; }

.countsCard{
  margin-top:12px;
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
  background:#fff;
}

.countsTitle{
  font-weight:900;
  font-size:14px;
  margin-bottom:10px;
}

.countsGrid{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
}

.countRow{
  display:grid;
  grid-template-columns: 70px 1fr 70px;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
}

.countRow.good{
  border-color: rgba(22,101,52,.20);
  background: rgba(22,163,74,.08);
}

.countRow.bad{
  border-color: rgba(153,27,27,.18);
  background: rgba(239,68,68,.08);
}

.elTag{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 10px;
  border-radius:999px;
  background: rgba(99,102,241,.12);
  color:#3730a3;
  font-weight:900;
  font-size:13px;
}

.countNum{
  font-weight:900;
  text-align:center;
  font-variant-numeric: tabular-nums;
}

.mid{
  color:var(--muted);
  font-size:13px;
  text-align:center;
}

.simHint{
  margin:12px 0 0;
  color:var(--muted);
  font-size:13px;
  text-align:center;
}
