/* ============================================================
   Vértice — base: reset, tipo, controles e superfícies
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

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

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

code,
kbd,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

code {
  background: var(--surface-2);
  border: 1px solid var(--border-faint);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-soft);
}

pre {
  margin: 0;
  overflow-x: auto;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: 12.5px;
  line-height: 1.7;
}

/* ---------------- scrollbar ---------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------- botões ---------------- */

.btn {
  --btn-h: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    transform var(--dur-fast) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 10px 30px -14px var(--accent-line);
}

.btn--primary:hover {
  background: var(--accent-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 14px 34px -14px var(--accent-line);
}

.btn--secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn--secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn--ghost {
  color: var(--muted);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  color: var(--danger);
  border-color: var(--border);
  background: transparent;
}

.btn--danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn--danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #1b0707;
  font-weight: 600;
}

.btn--sm {
  --btn-h: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn--lg {
  --btn-h: 48px;
  padding: 0 22px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

.btn--block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
  transform: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ---------------- formulários ---------------- */

.field {
  display: grid;
  gap: 7px;
}

.field > label,
.field-label {
  font-size: 12px;
  font-weight: 550;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--muted);
}

.input,
.select,
.textarea {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14.5px;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9ca3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--faint);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.field-hint {
  font-size: 12.5px;
  color: var(--faint);
  line-height: 1.45;
}

.form-error {
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
  cursor: pointer;
}

.checkbox input {
  margin: 2px 0 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input {
  padding-right: 42px;
}

.input-group .icon-btn {
  position: absolute;
  right: 4px;
}

/* ---------------- superfícies ---------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel--pad {
  padding: 22px;
}

.panel--soft {
  background: var(--surface-2);
  box-shadow: none;
}

.panel--glow {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(145deg, var(--accent-line), var(--border) 42%, var(--border)) border-box;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-faint);
}

.panel-head h2,
.panel-head h3 {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin-top: 3px;
  font-size: 13px;
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------------- badges e status ---------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tag--accent {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.tag--danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.tag--warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: color-mix(in srgb, var(--warning) 28%, transparent);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--faint) 14%, transparent);
}

.status.is-connected {
  color: var(--positive);
}

.status.is-connected::before {
  background: var(--positive);
  box-shadow: 0 0 0 3px var(--positive-soft);
}

.status.is-qr,
.status.is-connecting {
  color: var(--warning);
}

.status.is-qr::before,
.status.is-connecting::before {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
  animation: pulse-dot 1.8s var(--ease-in-out) infinite;
}

.status.is-disconnected::before {
  background: var(--faint);
}

.status.is-logged_out {
  color: var(--danger);
}

.status.is-logged_out::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.status.is-created::before {
  background: var(--info);
  box-shadow: 0 0 0 3px var(--info-soft);
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ---------------- tabelas ---------------- */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

.table th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-faint);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table .num {
  font-variant-numeric: tabular-nums;
}

/* ---------------- diálogos ---------------- */

dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  margin: auto;
}

dialog::backdrop {
  background: rgba(3, 4, 6, 0.6);
  backdrop-filter: blur(7px);
}

[data-theme="light"] dialog::backdrop {
  background: rgba(30, 28, 22, 0.32);
}

.dialog-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: dialog-in var(--dur) var(--ease);
  overflow: auto;
  max-height: calc(100vh - 40px);
}

dialog[open] .dialog-card {
  animation: dialog-in var(--dur) var(--ease);
}

.dialog--wide {
  width: min(760px, calc(100vw - 28px));
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.dialog-head h2 {
  font-size: 21px;
  letter-spacing: -0.03em;
}

.dialog-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-pop);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-soft);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease);
}

.toast::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--info);
  flex: none;
}

.toast.is-success::before {
  background: var(--positive);
}

.toast.is-error::before {
  background: var(--danger);
}

.toast.is-warning::before {
  background: var(--warning);
}

.toast.is-leaving {
  animation: toast-out var(--dur) var(--ease) forwards;
}

/* ---------------- diversos ---------------- */

.skeleton {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.5s linear infinite;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex: none;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 52px 24px;
  text-align: center;
}

.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent-strong);
  margin-bottom: 4px;
}

.empty-state h3 {
  font-size: 17px;
}

.empty-state p {
  max-width: 380px;
  color: var(--muted);
  font-size: 13.5px;
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 0;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  flex: none;
}

.avatar--accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent-line);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

/* ---------------- utilitários ---------------- */

.row {
  display: flex;
  align-items: center;
}

.col {
  display: flex;
  flex-direction: column;
}

.between {
  justify-content: space-between;
}

.center {
  justify-content: center;
}

.gap-4 {
  gap: 4px;
}
.gap-6 {
  gap: 6px;
}
.gap-8 {
  gap: 8px;
}
.gap-10 {
  gap: 10px;
}
.gap-12 {
  gap: 12px;
}
.gap-16 {
  gap: 16px;
}

.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.text-sm {
  font-size: 13px;
}

.text-xs {
  font-size: 12px;
}

.strong {
  font-weight: 600;
  color: var(--text);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden,
[hidden] {
  display: none !important;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------------- animações ---------------- */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  to {
    background-position: -400% 0;
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------- marca (compartilhada) ---------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  flex: none;
}

.brand-mark {
  width: 26px;
  height: 26px;
  color: var(--text);
}

.brand-word {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
  transform: translateY(0.5px);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  transition:
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}
