:root {
  --bg: #f6f6fa;
  --card: #ffffff;
  --text: #16161d;
  --muted: #6b6b7d;
  --border: #e5e5ee;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: #f1ebfe;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --fail: #b91c1c;
  --fail-soft: #fee2e2;
  --radius: 12px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 22px;
}
h2 {
  font-size: 20px;
}
h3 {
  font-size: 15px;
}

code,
pre,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.nowrap {
  white-space: nowrap;
}
.center {
  text-align: center;
}
.error {
  color: var(--fail);
}
.hint {
  color: var(--muted);
  font-size: 12px;
}
.hint.ok {
  color: var(--ok);
}
.hint.fail {
  color: var(--fail);
}

.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(16, 16, 29, 0.04);
}

.stack > * + * {
  margin-top: 14px;
}

.section > * + * {
  margin-top: 16px;
}

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover {
  background: #f3f3f8;
}
.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover {
  background: var(--primary-hover);
}
.btn.ghost {
  background: transparent;
}
.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* ---------- Formulários ---------- */

label {
  display: block;
  font-weight: 500;
}

input,
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
input:focus,
select:focus {
  border-color: var(--primary);
  outline: 3px solid var(--primary-soft);
}

.input-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.input-row input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Login ---------- */

.login {
  display: grid;
  min-height: 100vh;
  padding: 24px 16px;
  place-items: center;
}
.login-card {
  width: 100%;
  max-width: 400px;
}
.login-card .btn.primary {
  width: 100%;
}

/* ---------- Marca e topo ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  place-items: center;
}
.brand strong {
  display: block;
  font-size: 15px;
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.tabs {
  display: flex;
  flex: 1;
  gap: 4px;
  overflow-x: auto;
}
.tabs button {
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.tabs button:hover {
  background: #f3f3f8;
  color: var(--text);
}
.tabs button.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

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

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.section-head p {
  margin-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.status p + p {
  margin-top: 2px;
  word-break: break-all;
}

/* ---------- Selos ---------- */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.pill.fail {
  background: var(--fail-soft);
  color: var(--fail);
}
.pill.off {
  background: #f1f1f5;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- Tabelas ---------- */

.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td {
  border-bottom: 0;
}
td input {
  min-width: 180px;
  margin-top: 0;
}
.clamp {
  display: -webkit-box;
  max-width: 520px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ---------- Interruptor ---------- */

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.switch input {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  opacity: 0;
}
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d4d4de;
  cursor: pointer;
  transition: background 0.15s;
}
.slider::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 0.15s;
}
.switch input:checked + .slider {
  background: var(--primary);
}
.switch input:checked + .slider::before {
  transform: translateX(18px);
}
.switch input:focus-visible + .slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Código e resultados ---------- */

.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.copy-row code {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: #f3f3f8;
  overflow-x: auto;
  white-space: nowrap;
}

pre {
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: #111118;
  color: #ececf4;
  font-size: 12.5px;
  line-height: 1.55;
  overflow-x: auto;
}

.code-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.code-block pre {
  width: 100%;
}

.output {
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.output.fail {
  box-shadow: inset 3px 0 0 var(--fail);
}

.result.ok {
  border-color: #bbf7d0;
}
.result.fail {
  border-color: #fecaca;
}

p code {
  padding: 1px 6px;
  border-radius: 6px;
  background: #f3f3f8;
  font-size: 12.5px;
}

.notice {
  padding: 10px 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
}
.notice code {
  padding: 1px 6px;
  border-radius: 6px;
  background: #ffedd5;
}

/* ---------- Aviso flutuante ---------- */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px;
  border-radius: 10px;
  background: #16161d;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.toast.success {
  background: var(--ok);
}
.toast.error {
  background: var(--fail);
}

@media (max-width: 720px) {
  .topbar {
    padding: 10px 16px;
  }
  .tabs {
    flex-basis: 100%;
    order: 3;
  }
  .user {
    margin-left: auto;
  }
  .content {
    padding: 20px 16px 48px;
  }
}
