:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c232d;
  --border: #30363d;
  --border-strong: #475160;
  --text: #e6edf3;
  --muted: #aeb7c2; /* contraste AA sobre --surface e --bg */
  --primary: #238636;
  --primary-hover: #2ea043;
  --green: #56d364;
  --red: #f85149;
  --yellow: #e3b341;
  --focus: #4493f8;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(68, 147, 248, 0.32);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.icon--brand {
  width: 22px;
  height: 22px;
  color: var(--green);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6e7681;
}
.status--off {
  color: var(--muted);
}
.status--on {
  color: var(--green);
  background: rgba(46, 160, 67, 0.12);
  border-color: rgba(46, 160, 67, 0.5);
}
.status--on .dot {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(86, 211, 100, 0.6);
  animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(86, 211, 100, 0.55);
  }
  70%,
  100% {
    box-shadow: 0 0 0 6px rgba(86, 211, 100, 0);
  }
}

/* ---- Layout ---- */
.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}
.banner--error {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.5);
  color: #ffb4ad;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.field--inline {
  flex-direction: column;
}
.connect-error {
  margin: 4px 0 20px;
  font-size: 13px;
  color: var(--red);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover:not(:disabled) {
  background: #222b36;
  border-color: #5a6675;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn--primary {
  background: var(--primary);
  border-color: var(--primary-hover);
  color: #fff;
}
.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: #3fb950;
}
.btn--small {
  padding: 5px 12px;
  font-size: 12px;
}
.btn[aria-busy="true"] {
  color: transparent;
}
.btn[aria-busy="true"] .icon {
  opacity: 0;
}
.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: #fff;
  animation: spin 0.6s linear infinite;
}
.btn {
  position: relative;
}
.btn--primary[aria-busy="true"]::after,
.btn:not(.btn--primary)[aria-busy="true"]::after {
  color: var(--text);
}
.btn--primary[aria-busy="true"]::after {
  color: #fff;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* ---- Cards ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(236px, 1fr));
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.card h2 .icon {
  color: var(--muted);
}
.muted {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
  max-width: 44ch;
}

/* ---- Result ---- */
.result {
  margin-top: 18px;
  border-radius: 8px;
  padding: 13px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: reveal 0.3s var(--ease);
}
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
.result .icon {
  margin-top: 1px;
}
.result-text {
  min-width: 0;
}
.result strong {
  font-weight: 600;
}
.result--ok {
  border-color: rgba(46, 160, 67, 0.5);
  background: rgba(46, 160, 67, 0.09);
}
.result--ok .icon {
  color: var(--green);
}
.result--error {
  border-color: rgba(248, 81, 73, 0.5);
  background: rgba(248, 81, 73, 0.09);
}
.result--error .icon {
  color: var(--red);
}
.result--warn {
  border-color: rgba(227, 179, 65, 0.5);
  background: rgba(227, 179, 65, 0.09);
}
.result--warn .icon {
  color: var(--yellow);
}
.result .code {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-top: 4px;
}

/* ---- Progress ---- */
.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--primary-hover);
  transition: width 0.15s linear;
}
.progress-pct {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  min-width: 38px;
  text-align: right;
}
.result-actions {
  margin-top: 8px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary-hover);
  cursor: pointer;
}

/* ---- Panels ---- */
.panel {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  user-select: none;
}
.panel > summary::-webkit-details-marker {
  display: none;
}
.icon--chevron {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.2s var(--ease);
}
.panel[open] > summary .icon--chevron {
  transform: rotate(90deg);
}
.panel-body {
  padding: 4px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fields {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.field select,
#driver-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  accent-color: var(--primary-hover);
  min-width: 170px;
}
/* campos renderizados dentro de um cartao (ex.: "forçar" no dump) */
.card .field,
.card .check {
  margin-top: 12px;
}

/* ---- Log ---- */
.log-tools {
  display: flex;
  justify-content: flex-end;
}
.log {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
.log:empty::before {
  content: "Nenhum tráfego ainda. Conecte e execute uma ação.";
  color: #6e7681;
}
.log::-webkit-scrollbar {
  width: 10px;
}
.log::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
.log::-webkit-scrollbar-track {
  background: transparent;
}
.log {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.footnote {
  margin-top: 30px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
