/* Design tokens and layout follow WebVNA (github.com/vkopitsa/WebVNA). */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel2: #eef0f3;
  --fg: #1d2129;
  --muted: #5f6673;
  --line: #d6d9df;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --ok: #15803d;
  --err: #b91c1c;
  --chart-bg: #ffffff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--fg);
  background: var(--bg);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #171a21; --panel2: #1f232c; --fg: #e6e8ec; --muted: #9aa1ad; --line: #2c313c;
    --accent: #3b82f6; --ok: #4ade80; --err: #f87171; --chart-bg: #0b0d11;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a21; --panel2: #1f232c; --fg: #e6e8ec; --muted: #9aa1ad; --line: #2c313c;
  --accent: #3b82f6; --ok: #4ade80; --err: #f87171; --chart-bg: #0b0d11;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }

button, select, input, .button { font: inherit; color: inherit; }
button, .button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer;
  white-space: nowrap; text-decoration: none;
}
button:hover, .button:hover { border-color: var(--accent); }
button.small { padding: 2px 7px; font-size: 12px; }
button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
select { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; min-width: 0; }
input[type="color"] { width: 28px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); min-width: 0; }
.row input[type="range"] { flex: 1; }
label { color: var(--muted); font-size: 12px; }
output { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 2ch; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.toolbar .brand { font-weight: 700; margin-right: 8px; display: inline-flex; align-items: center; gap: 6px; }
.toolbar .spacer { flex: 1; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; font-variant-numeric: tabular-nums; }
.badge.ok { color: var(--ok); }
.badge.err { color: var(--err); }

.body { display: grid; grid-template-columns: 300px 1fr; min-height: 0; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panel { padding: 10px 12px; overflow-y: auto; flex: 1; }
.section { margin-bottom: 14px; }
.section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 6px; }
.row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.row > label { min-width: 84px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.kv > :nth-child(odd) { color: var(--muted); }

.main { display: flex; min-height: 0; min-width: 0; padding: 8px; }
.chart { position: relative; flex: 1; background: var(--chart-bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; min-height: 320px; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.chart canvas:active { cursor: grabbing; }

@media (max-width: 800px) {
  .app { height: auto; min-height: 100%; }
  .body { grid-template-columns: minmax(0, 1fr); }
  .main { order: -1; }
  .chart { aspect-ratio: 1 / 1; max-height: 75vh; min-height: 0; }
  .side { border-right: none; border-top: 1px solid var(--line); }
  .toolbar .brand { width: 100%; }
}
