/* Power Analyzer: app-specific styles (shared styles: /assets/css/site.css) */

:root {
  --accent: #1f6fb2;
  --accent-dark: #17578d;
  --ok: #2ea043;
  --busy: #e0a800;
  --danger: #b3261e;
  --volt: #c8323b;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem 1.25rem;
  align-items: start;
}
.app-head, .banner, .help { grid-column: 1 / -1; }
.app-head { max-width: 80ch; }
.app-head h1 { margin: 0 0 0.35rem; font-size: 2rem; color: var(--brand); }
.app-head p { margin: 0; color: var(--ink-soft); }
.banner { margin: 0; padding: 0.75rem 1rem; background: #fdecea; border-left: 4px solid var(--danger); border-radius: 4px; color: #7a1c1c; font-weight: 700; }

.main-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem 1.1rem; min-width: 0; }
.panel h2 { margin: 0 0 0.75rem; font-size: 1.0625rem; color: var(--brand); }
.panel h3 { margin: 0 0 0.4rem; font-size: 0.875rem; }

/* ---------- controls ---------- */

.btn {
  font: inherit; font-size: 0.9375rem; font-weight: 700; color: var(--ink); background: var(--surface);
  border: 1px solid #c5c8d4; border-radius: 5px; padding: 0.5rem 0.9rem; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: #edf4fb; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-small { font-size: 0.8125rem; padding: 0.3rem 0.65rem; }
input[type="number"], input[type="text"], select {
  font: inherit; font-size: 0.9375rem; padding: 0.35rem 0.5rem; border: 1px solid #c5c8d4; border-radius: 5px;
  background: var(--surface); color: var(--ink); min-width: 0; width: 100%;
}
input:disabled, select:disabled { opacity: 0.55; }
.field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0 0 0.7rem; min-width: 0; }
.field > span:first-child { font-weight: 700; font-size: 0.8125rem; }
.inunit { position: relative; display: block; }
.inunit input { padding-right: 2.6rem; font-variant-numeric: tabular-nums; }
.inunit i { position: absolute; right: 0.55rem; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 0.8125rem; color: var(--ink-soft); pointer-events: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- chart ---------- */

.chart-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.chart-head h2 { margin: 0 0 0.15rem; }
.chart-sub { margin: 0; font-size: 0.875rem; color: var(--ink-soft); }
.chart-tools { display: flex; gap: 0.35rem; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.5rem 0 0.3rem; font-size: 0.8125rem; min-height: 1.1em; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i { display: inline-block; width: 1.4rem; height: 0; border-top: 2px solid; }
.legend i.dash { border-top-style: dashed; }
.chart-wrap { position: relative; height: clamp(260px, 52vh, 470px); }
#chart { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.readout { margin: 0.4rem 0 0; min-height: 1.3em; font-size: 0.8125rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.readout b { color: var(--ink); }
.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem 1.25rem; margin: 0.7rem 0 0; }
.summary:empty { display: none; }
.summary div { border-left: 3px solid var(--accent); padding: 0.1rem 0 0.1rem 0.6rem; }
.summary dt { font-size: 0.75rem; color: var(--ink-soft); }
.summary dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- measurements ---------- */

.runs-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.runs-head h2 { margin: 0; }
.runs-tools { display: flex; gap: 0.35rem; }
.hint { margin: 0.4rem 0 0.6rem; font-size: 0.8125rem; color: var(--ink-soft); }
.runs { display: flex; flex-direction: column; border: 1px solid #e3e5ec; border-radius: 6px; max-height: 22rem; overflow: auto; }
.runs:empty::before { content: "No measurements yet. They appear here after each test."; padding: 0.7rem; font-size: 0.875rem; color: var(--ink-soft); }
.run-row {
  display: grid; grid-template-columns: 1.4rem minmax(0, 1.4fr) 6.5rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: center;
  padding: 0.35rem 0.6rem; border-bottom: 1px solid #f0f1f5; font-size: 0.875rem; cursor: pointer;
}
.run-row:hover { background: #f5f8fc; }
.run-row.on { background: #edf4fb; box-shadow: inset 3px 0 0 var(--accent); }
.run-row input[type="checkbox"] { width: 1rem; height: 1rem; margin: 0; }
.run-row .nm { display: flex; flex-direction: column; min-width: 0; }
.run-row .nm b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-row .nm small { color: var(--ink-soft); font-size: 0.75rem; }
.run-row .ty { color: var(--ink-soft); font-size: 0.8125rem; }
.run-row .key { font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-row .acts { display: flex; gap: 0.2rem; }
.run-row .acts button { border: 0; background: none; color: var(--ink-soft); cursor: pointer; padding: 0.2rem 0.35rem; border-radius: 4px; font: inherit; font-size: 0.8125rem; }
.run-row .acts button:hover { background: #e3edf8; color: var(--ink); }
.run-row .acts .del:hover { background: #fdecea; color: var(--danger); }
.run-row .sw { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.35rem; vertical-align: 0.05rem; }

/* ---------- analyzer panel ---------- */

.conn { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.6rem; font-weight: 700; font-size: 0.9375rem; overflow-wrap: anywhere; }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: #b9bccb; flex: none; }
.conn.connected .dot { background: var(--ok); }
.conn.busy .dot { background: var(--busy); }
.dev-btns { display: grid; grid-template-columns: 1fr auto; gap: 0.4rem; }
.meter { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 1rem 0 0.8rem; }
.mblock { background: #f6f7fa; border-radius: 6px; padding: 0.5rem 0.65rem; }
.mblock h3 { font-size: 0.8125rem; margin-bottom: 0.3rem; }
.mblock h3 small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.7rem; }
.mval { display: flex; align-items: baseline; justify-content: space-between; font-variant-numeric: tabular-nums; }
.mval b { font-size: 1.25rem; font-family: var(--mono); font-weight: 700; letter-spacing: -0.02em; }
.mval:first-of-type b { color: var(--volt); }
.mval:nth-of-type(2) b { color: var(--accent); }
.mval span { font-size: 0.8125rem; color: var(--ink-soft); }
.meter.stale b { color: #9aa0ad !important; }
.load { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.4rem; align-items: end; }
.load .field { margin: 0; }
.load-state { margin: 0.45rem 0 0; font-size: 0.8125rem; color: var(--ink-soft); min-height: 1.2em; }
.load-state.on { color: #8a5a00; font-weight: 700; }

/* ---------- test panel ---------- */

.test-info { margin: -0.2rem 0 0.7rem; font-size: 0.875rem; color: var(--ink-soft); }
.wiring { margin: 0 0 0.8rem; }
.wiring svg { width: 100%; height: auto; display: block; }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.5rem; }
.cal p { margin: 0 0 0.5rem; font-size: 0.875rem; }
.cal-g { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.5rem; }
.cal-out { margin: 0 0 0.8rem; padding: 0.5rem 0.6rem; background: #10141b; color: #d6dde7; border-radius: 6px; font-family: var(--mono); font-size: 0.78rem; white-space: pre-wrap; }
.cal-out:empty { display: none; }
.run { display: flex; gap: 0.5rem; }
.run #btn-start { flex: 1; }
.status { margin: 0.6rem 0 0; font-size: 0.875rem; color: var(--ink-soft); min-height: 1.2em; overflow-wrap: anywhere; }
.status.warn { color: #8a5a00; font-weight: 700; }
.status.err { color: var(--danger); font-weight: 700; }

/* ---------- help ---------- */

.help { margin-bottom: 1.5rem; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
.help ul { margin: 0; padding-left: 1.2rem; font-size: 0.9375rem; }
.help li { margin: 0.35rem 0; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .main-col { display: contents; }
  .chart-panel { order: 1; }
  .side { order: 2; }
  .runs-panel { order: 3; }
  .help { order: 4; }
  .help-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .app { padding: 1rem 0.75rem 0; }
  .app-head h1 { font-size: 1.6rem; }
  .run-row { grid-template-columns: 1.4rem minmax(0, 1fr) auto; }
  .run-row .ty, .run-row .key { display: none; }
  .chart-head { flex-direction: column; }
}
