:root{
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15,23,42,0.14);
  --shadow: 0 12px 30px rgba(2,6,23,0.08);
  --radius: 18px;
}

*{ box-sizing: border-box; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

a{ color: inherit; }

.lab{
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.lab header{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.lab h1{
  margin:0;
  font-size: 1.3rem;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.lab .sub{
  margin:0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.badge{
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 980px){
  .grid{ grid-template-columns: 370px 1fr; align-items: start; }
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card .card-h{
  padding: 0.85rem 0.95rem 0.6rem;
  border-bottom: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 0.75rem;
}
.card .card-h h2{
  margin:0;
  font-size: 1rem;
  font-weight: 900;
}
.card .card-b{ padding: 0.9rem 0.95rem 1rem; }

.controls{
  display:flex;
  flex-direction: column;
  gap: 0.85rem;
}

.row{
  display:flex;
  flex-direction: column;
  gap: 0.35rem;
}

label{
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 650;
}

select, input[type="number"], input[type="range"]{
  width:100%;
}

select, input[type="number"]{
  padding: 0.55rem 0.6rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 0.95rem;
}

input[type="range"]{
  accent-color: var(--text);
}

.btns{
  display:flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button{
  border: 1px solid var(--border);
  background: var(--text);
  color: #fff;
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  font-weight: 750;
  cursor: pointer;
}
button:hover{ filter: brightness(1.05); }
button.secondary{
  background: var(--card);
  color: var(--text);
}
button.secondary:hover{ background: rgba(15,23,42,0.06); }

.metrics{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}
@media (min-width: 560px){
  .metrics{ grid-template-columns: repeat(3, minmax(0,1fr)); }
}

.metric{
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.65rem 0.7rem;
  background: rgba(15,23,42,0.02);
}
.metric .k{
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}
.metric .v{
  font-size: 1.05rem;
  font-weight: 900;
  margin-top: 0.2rem;
}

.canvasWrap{
  padding: 0.85rem 0.95rem 1rem;
}
.canvasWrap canvas{
  width: 100% !important;
  height: 320px !important;
}

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

details{
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.6rem 0.7rem;
  background: rgba(15,23,42,0.02);
}
details summary{
  cursor: pointer;
  font-weight: 800;
}
details .small{ margin-top: 0.5rem; }
