:root{
  --bg:#f6f8fb;
  --card:#ffffff;
  --accent:#2563eb;
  --muted:#6b7280;
  --panel-shadow: 0 6px 18px rgba(15,23,42,0.06);
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background:var(--bg);
  color:#0f172a;
  padding:18px;
}
main{
  max-width:1200px;
  margin:0 auto;
  background:var(--card);
  padding:18px;
  border-radius:8px;
  box-shadow:var(--panel-shadow);
}
header h1{margin:0 0 6px 0}
.muted{color:var(--muted); font-size:13px}

/* Responsive grid: two columns on wide screens, single column under 880px */
.grid{
  display:grid;
  grid-template-columns: 320px 1fr;
  grid-auto-rows: auto;
  gap:16px;
  align-items:start;
}
@media (max-width: 880px) {
  .grid{
    grid-template-columns: 1fr;
  }
  .chart { order: 2; }
  .debug-table { order: 3; }
  .inputs { order: 1; }
}

.panel{
  background:linear-gradient(180deg,#fff,#fbfdff);
  padding:12px;
  border-radius:8px;
  box-shadow:0 2px 8px rgba(12,15,30,0.03);
}

.inputs label{
  display:flex;
  flex-direction:column;
  margin-bottom:8px;
  font-size:14px;
}
.inputs select, .inputs input[type="number"]{
  padding:8px;
  border-radius:6px;
  border:1px solid #e6eef6;
  width:100%;
  margin-top:6px;
}
.checkbox{display:flex;align-items:center;gap:8px;margin-top:6px}
.actions{display:flex;gap:8px;margin-top:8px}
button{background:var(--accent);border:none;color:#fff;padding:8px 10px;border-radius:6px;cursor:pointer}
button:active{transform:translateY(1px)}

.computed{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:8px;font-size:14px}
.computed div{padding:6px;background:#fbfdff;border-radius:6px;border:1px solid #eef5ff}

/* Chart panel */
.chart{grid-column:2 / 3}
.chart canvas.responsive-canvas{
  width:100%;
  display:block;
  aspect-ratio: 700/320;
  border-radius:6px;
  border:1px solid #e6eefb;
}

/* Horizontal menu */
.menu-row{
  display:flex;
  gap:6px;
  margin-top:8px;
  align-items:center;
  overflow-x:auto;
  padding-bottom:6px;
}
.menu-row::-webkit-scrollbar{height:8px}
.menu-row.labels .menu-cell{background:#fff;border:1px solid #eef2f7;color:#6b7280;padding:6px 8px;border-radius:6px;min-width:48px;text-align:center;font-weight:600;flex:0 0 auto}
.menu-row.values .menu-cell{background:#fff9f0;border:1px solid #fde3c8;color:#b45309;padding:6px 8px;border-radius:6px;min-width:48px;text-align:center;font-weight:700;flex:0 0 auto}
.menu-cell{font-size:13px}

/* debug table - allow scroll horizontally on small screens */
.debug-table{grid-column:1 / 2}
.table-scroll{
  overflow:auto;
  max-width:100%;
}
.table-scroll table{width:100%;border-collapse:collapse;margin-top:8px;min-width:320px}
.table-scroll th, .table-scroll td{padding:6px;border-bottom:1px solid #eef2f7;text-align:right}
.table-scroll th{background:#fbfdff;font-weight:600}
.num{text-align:right}

.legend{margin-top:8px;display:flex;align-items:center;gap:8px;color:var(--muted)}
.leg-swatch{width:36px;height:8px;background:var(--accent);display:inline-block;border-radius:3px}
footer{margin-top:12px;font-size:13px;color:var(--muted)}
