/* ── Reset & base ─────────────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin:0; padding:0; }

/* ── Debug tags ───────────────────────────────────────────────────────────── */
.tagged { position: relative; }
.tag {
  position: absolute; bottom: 2px; right: 4px;
  font-size: 9px; font-family: monospace;
  color: rgba(255,255,255,0.15);
  pointer-events: none; user-select: none;
  line-height: 1; white-space: nowrap; z-index: 10;
}
.canvas-tag-wrap { position: relative; display: inline-block; }
.canvas-tag-wrap .tag { bottom: 5px; right: 7px; color: rgba(255,255,255,0.2); }
.controls.tagged>.tag,.readouts.tagged>.tag,.legend.tagged>.tag { top:auto; bottom:3px; }
.rd.tagged { padding-bottom:14px; }
.rd.tagged>.tag { bottom:2px; right:4px; }
button.tagged { padding-bottom:14px; }
button.tagged>.tag { bottom:2px; right:4px; }
.cbtn.tagged { padding-bottom:14px; }
.leg.tagged { padding-bottom:12px; position:relative; }

body {
  font-family: Arial, sans-serif;
  background: #1a1a1f;
  color: #f0f0f5;
  padding: 16px;
  min-height: 100vh;
  font-size: 14px;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h2 { font-size: 19px; font-weight: 500; color: #ffffff; letter-spacing: 0.3px; }
.subtitle { font-size: 12px; color: #888; font-family: monospace; margin-top: -8px; }

/* ── Controls bar ─────────────────────────────────────────────────────────── */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  background: #252530;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  padding: 12px 16px;
}
.btn-group { display: flex; gap: 8px; }

button {
  background: #2e2e3e;
  border: 1px solid #4a4a5e;
  color: #ffffff;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: #3a3a4e; }
button:active { transform: scale(0.97); }

.ctrl { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #e8e8ec; }
.ctrl label { white-space: nowrap; }

.ctrl input[type="number"], .ctrl select {
  width: 86px;
  background: #1e1e28;
  border: 1px solid #3a3a4a;
  color: #ffffff;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 5px;
}
.ctrl select { width: 96px; }
.ctrl input[type="number"]:focus, .ctrl select:focus { outline: none; border-color: #5a7fd4; }

.unit { color: #c0c0c8; font-size: 13px; }
.period-num { width: 86px; }

/* ── Readouts ─────────────────────────────────────────────────────────────── */
.readouts { display: flex; gap: 10px; flex-wrap: wrap; }
.rd {
  background: #252530;
  border: 1px solid #3a3a4a;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  color: #c8c8d0;
  min-width: 102px;
}
.rdv { display: block; font-size: 17px; font-weight: 600; color: #ffffff; margin-top: 3px; font-family: monospace; }

/* ── Canvas ───────────────────────────────────────────────────────────────── */
.canvas-row { display: flex; gap: 14px; flex-wrap: wrap; }
canvas {
  border-radius: 8px;
  border: 1px solid #3a3a4a;
  display: block;
  background: #12121a;
  cursor: crosshair;
}

/* ── Legend ───────────────────────────────────────────────────────────────── */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: #d0d0d8; align-items: center; }
.leg { display: flex; align-items: center; gap: 6px; }
.legdot { width: 24px; height: 3px; border-radius: 2px; }
.sep { width: 1px; height: 28px; background: #3a3a4a; margin: 0 4px; }

/* ── Section divider ──────────────────────────────────────────────────────── */
.section-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 0 2px;
  position: relative;
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px; background: #3a3a5a;
}
.divider-label {
  font-size: 13px; font-family: monospace;
  color: #b8b8d8; white-space: nowrap; letter-spacing: 0.5px;
}

/* ── Phase input blocks (same look as ThreeFase RLC panel) ────────────────── */
.rlc-panel {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  background: #252530;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  padding: 12px 16px;
  gap: 16px;
}
.rlc-block {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 150px;
  position: relative;
}
.rlc-title { font-size: 15px; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 3px; }
.rlc-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #ececf2; }
.rlc-row label { min-width: 90px; white-space: nowrap; }
.rlc-inp {
  width: 90px;
  background: #1e1e28;
  border: 1px solid #3a3a4a;
  color: #ffffff;
  font-size: 14px;
  padding: 5px 7px;
  border-radius: 4px;
}
.rlc-inp:focus { outline: none; border-color: #5a7fd4; }
.rlc-sep { width: 1px; align-self: stretch; background: #3a3a4a; margin: 0 4px; }

/* ── Fault presets ────────────────────────────────────────────────────────── */
.fault-presets {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 220px; padding-left: 6px;
}
.fault-title {
  font-size: 13px;
  color: #b8b8d8;
  font-family: monospace;
  margin-bottom: 3px;
  letter-spacing: 0.3px;
}
.fault-btn {
  text-align: left !important;
  background: #1e1e28;
  border: 1px solid #4a4a5e;
  color: #ececf2;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.fault-btn:hover { background: #2a2a38; border-color: #e0c060; color: #f0d070; }

.cbtn {
  background: #2e2e3e;
  border: 1px solid #4a4a5e;
  color: #e8e8ec;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}
.cbtn:hover { background: #3a3a4e; color: #ececf2; }

/* ── Settings grid ────────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.setting-card {
  background: #252530;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 7px;
  position: relative;
}
.setting-head {
  font-size: 15px;
  color: #f0f0f5;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid #3a3a4a;
  padding-bottom: 6px;
  margin-bottom: 3px;
}
.ansi-badge {
  display: inline-block;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  color: #1a1a1f;
  letter-spacing: 0.5px;
}
.ansi-50  { background: #ff8a80; }
.ansi-51  { background: #e0c060; }
.ansi-50n { background: #ffb060; }
.ansi-51n { background: #d0a040; }
.ansi-52  { background: #80c0ff; }

/* ── Status / LEDs ────────────────────────────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 12px;
}
.status-card {
  background: #252530;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
.status-head {
  font-size: 15px;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid #3a3a4a;
  padding-bottom: 6px;
}
.status-row { display: flex; gap: 16px; align-items: center; padding: 4px 0; }
.led {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: monospace; font-size: 12px; font-weight: 700;
  letter-spacing: 0.8px;
  color: #888;
  position: relative;
  padding-left: 22px;
}
.led::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #2a2a35;
  border: 1px solid #3a3a4a;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
}
.led::after { content: attr(data-label); }
.led.pickup-on { color: #ffd070; }
.led.pickup-on::before {
  background: radial-gradient(circle at 30% 30%, #ffe690, #d0a020 70%);
  box-shadow: 0 0 10px #f0c050, inset 0 0 4px rgba(0,0,0,0.3);
  border-color: #f0c050;
}
.led.trip-on { color: #ff6060; }
.led.trip-on::before {
  background: radial-gradient(circle at 30% 30%, #ff9090, #c02020 70%);
  box-shadow: 0 0 14px #ff4040, inset 0 0 4px rgba(0,0,0,0.3);
  border-color: #ff5050;
}
.status-detail {
  font-size: 12px;
  color: #b0b0b8;
  font-family: monospace;
  line-height: 1.6;
}
.status-detail span { color: #ffffff; font-weight: 600; }

/* ── Breaker ──────────────────────────────────────────────────────────────── */
.breaker-card { align-items: stretch; }
.breaker-display {
  font-family: monospace;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  padding: 10px;
  border-radius: 6px;
  background: #1e3a1e;
  color: #70e090;
  border: 1px solid #408050;
  letter-spacing: 1px;
  transition: all .2s;
}
.breaker-display.open {
  background: #3a1e1e;
  color: #ff7070;
  border-color: #804040;
}

/* ── Event log ────────────────────────────────────────────────────────────── */
.event-log {
  background: #252530;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: monospace;
  font-size: 12px;
  position: relative;
}
.event-head {
  display: flex;
  gap: 10px;
  color: #b8b8d8;
  border-bottom: 1px solid #3a3a4a;
  padding-bottom: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.evh-time { width: 110px; }
.evh-fn { width: 70px; }
.evh-msg { flex: 1; min-width: 200px; }
.evh-data { width: 220px; }
.event-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
}
.event-row {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px dashed #2a2a38;
  color: #d0d0d8;
}
.event-row.ev-trip { color: #ff8080; font-weight: 700; }
.event-row.ev-pickup { color: #f0c050; }
.event-row.ev-reset { color: #70e090; }
.event-row.ev-info { color: #a0c0e0; }
.ev-time { width: 110px; color: #888; }
.ev-fn { width: 70px; font-weight: 700; }
.ev-msg { flex: 1; min-width: 200px; }
.ev-data { width: 220px; color: #b0b0b8; font-size: 11px; }

/* ── Formulas panel (igual ThreeFase) ─────────────────────────────────────── */
.rlc-formulas {
  background: #252530;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 10px;
  font-size: 14px;
  color: #f0f0f5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rlc-formulas > strong {
  color: #f0d070;
  font-size: 15px;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.formula-row {
  display: flex; align-items: baseline; gap: 14px;
  padding: 4px 0;
  border-bottom: 1px dashed #353548;
}
.formula-row:last-child { border-bottom: none; }
.formula-row .f-label { color: #d0d0d8; min-width: 220px; font-size: 13.5px; }
.formula-row .f-eq { color: #ffffff; font-family: monospace; font-size: 14px; }
.formula-row.formula-highlight {
  background: rgba(240,208,112,0.10);
  border-radius: 5px;
  padding: 6px 8px;
  margin: 3px -6px;
}
.formula-row.formula-highlight .f-eq { color: #f0d070; font-weight: 700; }

/* ── Checkbox global ──────────────────────────────────────────────────────── */
input[type="checkbox"] { accent-color: #5a7fd4; cursor: pointer; width:14px; height:14px; }

/* ════════════════════════════════════════════════════════════════════════════
   Rodapé didático — Documentação detalhada
   ════════════════════════════════════════════════════════════════════════════ */
.doc-block {
  background: #1e1e28;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  padding: 22px 30px;
  color: #d8d8e0;
  line-height: 1.65;
  font-size: 14px;
  position: relative;
}
.doc-sec {
  padding: 12px 0;
  border-bottom: 1px dashed #2f2f44;
}
.doc-sec:last-of-type { border-bottom: none; }
.doc-sec h3 {
  color: #f0d070;
  font-size: 18px;
  font-weight: 700;
  margin: 8px 0 12px 0;
  letter-spacing: 0.2px;
}
.doc-sec h4 {
  color: #b8d8f8;
  font-size: 15px;
  font-weight: 600;
  margin: 14px 0 6px 0;
  letter-spacing: 0.2px;
}
.doc-sec p {
  margin: 6px 0 8px 0;
  color: #d0d0d8;
}
.doc-sec p strong, .doc-sec li strong { color: #ffffff; }
.doc-sec em { color: #b8d8f8; font-style: italic; }
.doc-sec ul, .doc-sec ol {
  margin: 6px 0 10px 24px;
  color: #d0d0d8;
}
.doc-sec li { margin: 3px 0; }
.doc-sec code {
  background: #12121a;
  border: 1px solid #2f2f44;
  border-radius: 3px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 12.5px;
  color: #f0d070;
}

.doc-eq {
  font-family: monospace;
  font-size: 14.5px;
  color: #f0d070 !important;
  background: rgba(240,208,112,0.07);
  border-left: 3px solid #f0d070;
  padding: 8px 14px;
  margin: 8px 0 !important;
  border-radius: 0 4px 4px 0;
}

.doc-pre {
  font-family: monospace;
  font-size: 12.5px;
  color: #d8d8e0;
  background: #12121a;
  border: 1px solid #2f2f44;
  border-radius: 5px;
  padding: 10px 14px;
  margin: 6px 0 10px;
  white-space: pre;
  overflow-x: auto;
  line-height: 1.5;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0 12px;
  background: #181820;
  border-radius: 6px;
  overflow: hidden;
}
.doc-table thead th {
  background: #2a2a38;
  color: #f0d070;
  text-align: left;
  padding: 8px 12px;
  font-weight: 700;
  border-bottom: 1px solid #3a3a4a;
  font-size: 12.5px;
  letter-spacing: 0.3px;
}
.doc-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid #25253a;
  color: #d8d8e0;
  vertical-align: top;
}
.doc-table tbody tr:last-child td { border-bottom: none; }
.doc-table tbody tr:hover td { background: #20202d; }
.doc-table tbody td:first-child {
  color: #b8d8f8;
  font-family: monospace;
  white-space: nowrap;
}

.doc-footer-note {
  margin-top: 16px !important;
  padding: 12px 14px;
  background: rgba(122,240,168,0.06);
  border-left: 3px solid #7af0a8;
  border-radius: 0 5px 5px 0;
  font-size: 13px;
  color: #d0d0d8;
}
.doc-footer-note strong { color: #7af0a8 !important; }
