/* style.css — instrumen bench lab tema terang, ramp graphite netral, skala 4px */

:root {
  --bg-deep: #fafafa;
  --bg: #f4f4f5;
  --panel: #ffffff;
  --panel2: #f4f4f5;
  --panel3: #e8e8ec;
  --line: rgba(23, 23, 23, 0.08);
  --line2: rgba(23, 23, 23, 0.15);
  --text: #171717;
  --text2: #525252;
  --dim: #737373;
  --accent: #b45309;
  --accent-dim: rgba(180, 83, 9, 0.10);
  --ok: #15803d;
  --ok-bg: rgba(22, 163, 74, 0.08);
  --ok-line: rgba(22, 163, 74, 0.25);
  --warn: #b45309;
  --warn-bg: rgba(180, 83, 9, 0.09);
  --warn-line: rgba(180, 83, 9, 0.26);
  --err: #dc2626;
  --err-bg: rgba(220, 38, 38, 0.07);
  --err-line: rgba(220, 38, 38, 0.26);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.07);

  --sans: "IBM Plex Sans", "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Liberation Mono", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------- topbar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--accent);
}

.logo {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 16px;
  line-height: 1;
  color: var(--text);
}

.brand .sub {
  color: var(--dim);
  font-size: 13px;
  padding-left: 8px;
  border-left: 1px solid var(--line2);
}

.conn {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hdrstats {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
}

.hstat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.hstat label {
  font-size: 11px;
  line-height: 1;
  color: var(--dim);
}

.hstat b {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--panel2);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  color: var(--dim);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}

.pill.on, .pill.ok {
  color: var(--ok);
  border-color: var(--ok-line);
  background: var(--ok-bg);
}

.pill.on::before, .pill.ok::before {
  background: var(--ok);
}

.pill.off {
  color: var(--dim);
}

.pill.warn {
  color: var(--warn);
  border-color: var(--warn-line);
  background: var(--warn-bg);
}

.pill.warn::before {
  background: var(--warn);
}

/* ---------------- kontrol, tombol, input ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line2);
  background: var(--panel);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease), transform 120ms var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--panel2);
  border-color: rgba(23, 23, 23, 0.28);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn.sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--r-sm);
  background: var(--panel);
}

.btn.primary {
  background: var(--text);
  border-color: var(--text);
  color: #ffffff;
}

.btn.primary:hover:not(:disabled) {
  background: #2c2c30;
  border-color: #2c2c30;
}

.btn.estop {
  height: 36px;
  padding: 0 12px;
  background: var(--err-bg);
  border-color: var(--err-line);
  color: #b91c1c;
  font-weight: 600;
  gap: 8px;
  box-shadow: none;
}

.btn.estop:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(220, 38, 38, 0.45);
  color: #991b1b;
}

.kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid rgba(185, 28, 28, 0.22);
  background: rgba(255, 255, 255, 0.72);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: inherit;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

select, input[type="number"], input[type="text"], .term-input input {
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line2);
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}

select {
  font-family: var(--sans);
  padding-right: 24px;
  cursor: pointer;
}

select:hover, input[type="number"]:hover, input[type="text"]:hover, .term-input input:hover {
  border-color: rgba(23, 23, 23, 0.30);
}

select:focus, input:focus {
  border-color: var(--accent);
}

input[type="number"] {
  width: 88px;
}

/* custom range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
  margin: 4px 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: #d8dade;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  margin-top: -5px;
  transition: transform 120ms var(--ease);
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #d8dade;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
}

.chk input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.block-chk {
  margin: 8px 0 12px;
}

/* ---------------- layout utama ---------------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  min-height: 0;
  animation: fadeIn 280ms var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.controls {
  background: var(--panel);
  overflow-y: auto;
}

.block {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.block:last-child {
  border-bottom: none;
}

h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 8px;
}

h3 .hint {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--dim);
}

.hint {
  color: var(--dim);
  font-size: 12px;
  margin: 8px 0 0;
  line-height: 1.45;
}

.dim { color: var(--dim); }
.mt16 { margin-top: 16px; }

/* segmented control */

.seg {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel2);
  gap: 4px;
}

.seg button {
  flex: 1;
  height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}

.seg button.on {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.seg button:hover:not(.on) {
  color: var(--text2);
}

.seg.mini {
  margin-left: auto;
  padding: 2px;
}

.seg.mini button {
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
}

.sp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.sp-row.tight {
  margin-top: 8px;
  margin-bottom: 0;
}

.sp-row input[type="number"] {
  flex: 1;
  height: 36px;
  font-size: 15px;
  font-weight: 500;
  padding: 0 10px;
}

.unit {
  color: var(--dim);
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
}

.btnrow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.btnrow .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 8px;
}

.block > .chk {
  margin-top: 12px;
}

.btnrow.presets {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.btnrow.presets .btn {
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
}

.btnrow.nudges .btn {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.btnrow.compact {
  margin-top: 0;
  flex: 0 0 auto;
}

.btnrow.compact .btn {
  flex: 0 0 auto;
  padding: 0 12px;
}

/* ---------------- workspace & strip telemetri ---------------- */

.workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.telemetry-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.2;
}

.stat-val-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-val-row b {
  font-family: var(--mono);
  font-size: 26px;
  line-height: 1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-unit {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

.diag-strip {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.diag-item {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.diag-item.wide {
  margin-left: auto;
}

.diag-lbl {
  font-size: 12px;
  color: var(--dim);
}

.diag-item b {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ---------------- area tab utama ---------------- */

.mainarea {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  overflow-x: auto;
}

.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 140ms var(--ease), border-color 140ms var(--ease);
}

.tabs button:hover {
  color: var(--text);
}

.tabs button.on {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tabs button.on svg {
  color: var(--accent);
}

.tabpane {
  display: none;
  flex: 1;
  min-height: 0;
  padding: 16px 20px;
  overflow: auto;
}

.tabpane.on {
  display: flex;
  flex-direction: column;
}

#tab-scope.on {
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.series-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.toolbar .sep {
  width: 1px;
  height: 16px;
  background: var(--line2);
}

/* chip toggle sinyal */
.chk.chip {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--panel2);
  font-size: 12px;
  color: var(--dim);
  gap: 6px;
  transition: border-color 140ms var(--ease), color 140ms var(--ease), background-color 140ms var(--ease);
}

.chk.chip input[type="checkbox"] {
  display: none;
}

.chk.chip:has(input:checked) {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chk.chip:hover {
  border-color: rgba(23, 23, 23, 0.28);
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.35;
  flex-shrink: 0;
}

.chk.chip:has(input:checked) .swatch {
  opacity: 1;
}

.s-rpm { background: #168049; }
.s-sp { background: #b45309; }
.s-freq { background: #0e7490; }
.s-per { background: #7c5295; }
.s-duty { background: #2563eb; }
.s-cur { background: #dc2626; }
.s-err { background: #9d4b7a; }
.s-vsup { background: #a16207; }

.chartwrap {
  flex: 1;
  min-height: 240px;
  position: relative;
  border: 1px solid var(--line2);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #ffffff;
}

.chartwrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chartwrap.sm {
  height: 320px;
  flex: none;
}

.scope-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.legend {
  display: flex;
  gap: 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text2);
  flex-wrap: wrap;
}

.legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .lg i {
  width: 12px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
}

.hint.flow {
  margin: 0;
  font-size: 12px;
  color: var(--dim);
}

.hint.flow b {
  color: var(--text2);
  font-weight: 500;
}

/* ---------- panel banyak sinyal (hidden default) ---------- */

.multigrid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

.multigrid[data-cols="1"] { grid-template-columns: 1fr; }
.multigrid[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }

.mpane {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #ffffff;
  min-height: 96px;
}

.mpane canvas { display: block; width: 100%; height: 100%; }

.mpane .mtitle {
  position: absolute;
  top: 8px;
  left: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
  pointer-events: none;
  background: rgba(255, 255, 255, 0.88);
  padding: 2px 6px;
  border-radius: 4px;
}

.mpane .mval {
  position: absolute;
  top: 8px;
  right: 10px;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  pointer-events: none;
  background: rgba(255, 255, 255, 0.88);
  padding: 2px 6px;
  border-radius: 4px;
}

.toolbar .lbl { font-size: 12px; color: var(--dim); }

/* ---------------- grid 2 kolom & subcard PID ---------------- */

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

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

.subcard {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
}

.pid-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.subcard-head h3 {
  margin: 0;
}

.subcard h3 {
  margin-bottom: 10px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.formula {
  font-family: var(--mono);
  color: var(--text2);
  margin: 0 0 12px;
}

/* ---------------- PID ---------------- */

.pidrow {
  display: grid;
  grid-template-columns: 108px 1fr 92px 84px;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  margin-bottom: 8px;
}

.pidrow label {
  font-size: 13px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pidrow input[type="range"] {
  width: 100%;
  margin: 0;
}

.pidrow > input[type="number"] {
  width: 92px;
  height: 32px;
  border-radius: var(--r-sm);
}

.pidrow .unit {
  font-size: 11px;
  text-align: left;
}

.pidrow.off {
  opacity: 0.42;
}

.termSw {
  accent-color: var(--ok);
}

.isolate-row {
  margin: 12px 0 4px;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.bar {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bar label {
  font-size: 12px;
  color: var(--text2);
  font-family: var(--mono);
}

.bar .track {
  height: 12px;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.bar .track i {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--accent);
  transition: transform 90ms var(--ease);
}

.bar b {
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.bar:nth-child(1) .track i { background: var(--accent); }
.bar:nth-child(2) .track i { background: var(--ok); }
.bar:nth-child(3) .track i { background: #7c5295; }
.bar:nth-child(4) .track i { background: #2563eb; }
.bar.out .track i { background: var(--text); }

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  font-size: 12px;
}

#classicForm, #errBox {
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px 14px;
}

#classicForm span:nth-child(4n+3),
#errBox span:nth-child(4n+3) {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

#classicForm {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.kv span:nth-child(odd) {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 12px;
}

.kv span:nth-child(even) {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.term-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  margin-left: 4px;
  border: 1px solid var(--line);
  color: var(--dim);
}

.term-tag.on {
  color: var(--ok);
  border-color: var(--ok-line);
  background: var(--ok-bg);
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 20px;
  font-size: 13px;
}

.metrics .m {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
}

.metrics .m span:first-child {
  color: var(--text2);
  font-size: 12px;
}

.metrics .m span:last-child {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ---------------- aturan tuning ---------------- */

.rules { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.rule {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--panel);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
}
.rule .rname { font-size: 13px; font-weight: 500; }
.rule .rform { grid-column: 1; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.rule .rnote { grid-column: 1; font-size: 12px; color: var(--dim); }
.rule .rvals { font-family: var(--mono); font-size: 12px; color: var(--accent); grid-column: 1; }
.rule .btn { grid-column: 2; grid-row: 1 / span 3; align-self: center; }

/* ---------------- log & terminal ---------------- */

.log, .term {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  overflow-y: auto;
  line-height: 1.65;
}

.log { height: 420px; }
.term { flex: 1; min-height: 220px; }

.term .rx { color: var(--text2); }
.term .tx { color: var(--accent); }
.term .ev { color: var(--ok); }
.term .err { color: var(--err); }

.term-input {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.term-input input {
  flex: 1;
}

.log .l-time { color: var(--dim); }
.log .l-info { color: var(--text2); }
.log .l-warn { color: var(--warn); }
.log .l-err { color: var(--err); }

details.ref {
  margin-top: 10px;
}

details.ref summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text2);
}

details.ref pre {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
  color: var(--text2);
  margin-top: 8px;
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--panel);
  border: 1px solid var(--line2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.err {
  border-color: var(--err-line);
  color: #b91c1c;
}

.toast.ok {
  border-color: var(--ok-line);
  color: var(--ok);
}

/* ---------------- scrollbar ---------------- */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--panel2); }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* ---------- Detail Data (hidden default) ---------- */

.tblwrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-md); max-height: 520px; }
.tblwrap.tall { max-height: 360px; }
table.dt { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
table.dt th, table.dt td { padding: 4px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.dt th { position: sticky; top: 0; background: var(--panel); color: var(--dim); font-weight: 500; z-index: 1; }
table.dt td.nm, table.dt th:first-child { text-align: left; }
table.dt td.nm { color: var(--text2); }
table.dt td.v { color: var(--text); font-weight: 500; }
table.dt td.u { color: var(--dim); text-align: left; padding-left: 2px; }
table.dt td.dim { color: var(--dim); text-align: left; }
table.dt tr.grp td { background: var(--panel); color: var(--dim); font-size: 11px; text-align: left; }
table.dt tbody tr:hover td { background: var(--panel2); }
table.dt.dense th, table.dt.dense td { padding: 3px 8px; }

#tab-detail .tblwrap { max-height: 420px; }
#tab-detail.on > * { flex: none; }
.btn.sm.on { background: var(--panel3); border-color: var(--line2); color: var(--text); }

/* keterangan di atas tiap tab */
.tabnote {
  margin: 0 0 12px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text2);
  font-size: 13px;
  line-height: 1.5;
  max-width: 90ch;
}

.tabnote.inline {
  margin: 0;
  padding: 0;
  border: none;
}

/* ---------------- responsif ---------------- */

@media (max-width: 1024px) {
  body { overflow: auto; height: auto; min-height: 100%; }
  .layout { grid-template-columns: 1fr; }
  .controls { overflow: visible; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hdrstats { display: none; }
  .brand .sub { display: none; }
  .chartwrap { min-height: 320px; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 10px; }
  .conn { flex-wrap: wrap; width: 100%; }
  .conn select { flex: 1 1 140px; min-width: 0; }
  .kbd { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .pidrow { grid-template-columns: 96px 1fr 76px; }
  .pidrow .unit { display: none; }
  #classicForm, #errBox { grid-template-columns: auto 1fr; }
  #classicForm span:nth-child(4n+3),
  #errBox span:nth-child(4n+3) { padding-left: 0; border-left: none; }
}
