:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, Arial, sans-serif; color: var(--text); background: var(--bg); }
body { min-height: 100vh; }

.page {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,.04);
}

.controls {
  padding: 18px;
  position: sticky;
  top: 18px;
  align-self: start;
}

.content {
  display: grid;
  gap: 18px;
}

.info {
  padding: 16px 18px;
}

.info-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

h1, h2 {
  margin: 0 0 10px;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.grid {
  display: grid;
  gap: 12px;
  margin-bottom: 10px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0,1fr));
}

label span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select, button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 11px 12px;
  font-size: 14px;
  background: #fff;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: #e5e7eb;
  color: #111827;
}

button:disabled {
  opacity: .7;
  cursor: wait;
}

.buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

section { margin-bottom: 18px; }

pre {
  margin: 14px 0 0;
  background: #0f172a;
  color: #e5e7eb;
  padding: 14px;
  border-radius: 12px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.pill {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 18px;
}

.chart-panel {
  padding: 8px;
}

.chart {
  width: 100%;
  height: 330px;
}

.chart.tall {
  height: 360px;
}

.bode-panel {
  padding: 8px;
}

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

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

th {
  background: #f9fafb;
  position: sticky;
  top: 0;
}

.formulas-panel,
.schema-panel,
.impedance-panel {
  padding: 16px 18px;
}

.formula-block {
  margin-top: 14px;
}

.formula-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.math-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  overflow-x: auto;
}

.split-two,
.two-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 18px;
}

.schema-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  overflow-x: auto;
}

.schematic-svg {
  width: 100%;
  min-width: 760px;
  height: auto;
  display: block;
}

.inline-note {
  align-self: end;
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
}

@media (max-width: 1280px) {
  .page {
    grid-template-columns: 1fr;
  }
  .controls {
    position: static;
  }
}

@media (max-width: 900px) {
  .charts-grid,
  .bode-grid,
  .grid.two,
  .buttons,
  .info-top,
  .two-panels,
  .split-two {
    grid-template-columns: 1fr;
    display: grid;
  }
  .pill {
    white-space: normal;
  }
}
