:root {
  --bg: #07111f;
  --bg-2: #0b1626;
  --surface: #101c2e;
  --surface-2: #132238;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(247, 199, 75, 0.28);
  --text: #f5f7fa;
  --text-muted: #9fb2c7;
  --text-dim: #6f8296;
  --gold: #f7c74b;
  --gold-2: #d99a05;
  --gold-soft: rgba(247, 199, 75, 0.13);
  --green: #35d397;
  --green-soft: rgba(53, 211, 151, 0.13);
  --red: #ff6b5f;
  --red-soft: rgba(255, 107, 95, 0.13);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 24px 70px -30px rgba(0, 0, 0, 0.75);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 80% -20%, rgba(247, 199, 75, 0.12), transparent 60%),
    radial-gradient(900px 520px at -10% 110%, rgba(2, 119, 91, 0.32), transparent 62%),
    var(--bg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
h1, h2, h3, h4, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
svg { width: 1em; height: 1em; }

.brand-eyebrow,
.gold-eyebrow {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 900;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 1.05fr) minmax(360px, 0.95fr);
}
.login-story {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
  border-right: 1px solid var(--border);
  background:
    radial-gradient(560px 420px at 88% 8%, rgba(247, 199, 75, 0.24), transparent 60%),
    radial-gradient(560px 440px at 6% 93%, rgba(13, 130, 96, 0.42), transparent 62%),
    linear-gradient(150deg, #142032 0%, #06131f 58%, #053b31 100%);
}
.login-brandline {
  display: flex;
  align-items: center;
  gap: 13px;
  position: relative;
  z-index: 1;
}
.brand-logo {
  object-fit: cover;
  border: 1px solid rgba(247, 199, 75, 0.42);
  background: #08111d;
  box-shadow: 0 0 28px rgba(247, 199, 75, 0.36);
}
.brand-logo-lg {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}
.login-brandline strong { display: block; font-size: 18px; }
.login-brandline span {
  display: block;
  margin-top: 2px;
  color: #b7d4d0;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 11px;
}
.login-copy { max-width: 560px; position: relative; z-index: 1; }
.login-copy h1 {
  margin-top: 14px;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}
.login-copy h1 span { color: var(--gold); }
.login-copy p {
  max-width: 510px;
  margin-top: 22px;
  color: #b9d0db;
  font-size: 16px;
  line-height: 1.7;
}
.login-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  max-width: 470px;
  margin-top: 32px;
}
.login-stats div {
  border: 1px solid rgba(247, 199, 75, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  padding: 14px;
}
.login-stats small {
  display: block;
  color: #8fb8b0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.login-stats strong {
  display: block;
  margin-top: 5px;
  color: var(--gold);
  font-size: 22px;
}
.login-story footer { color: #9ab5b5; font-size: 12px; }
.login-panel-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 42px;
}
.login-card {
  width: min(390px, 100%);
  background: transparent;
}
.access-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
}
.access-pill svg { width: 13px; height: 13px; color: var(--gold); }
.login-card h1 { margin-top: 16px; font-size: 30px; letter-spacing: -0.03em; }
.login-sub { color: var(--text-muted); font-size: 14px; margin: 6px 0 30px; }
.login-footer {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 24px;
}

/* Buttons and fields */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(180deg, #ffdd63 0%, #df9f00 100%);
  color: #1d1602;
  box-shadow: 0 14px 28px -12px rgba(247, 199, 75, 0.75);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 18px 38px -14px rgba(247, 199, 75, 0.9); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--gold);
  border-color: var(--border-strong);
  background: var(--gold-soft);
}
.btn-sm { min-height: 32px; padding: 7px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input:not([type="checkbox"]) {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  color: var(--text);
  padding: 10px 13px;
  outline: none;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.field input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(247, 199, 75, 0.14);
}
.group-search-field {
  position: relative;
  display: block;
  margin-bottom: 10px;
}
.group-search-field svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  pointer-events: none;
}
.group-search-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
  color: var(--text);
  padding: 8px 13px 8px 38px;
  outline: none;
  font-size: 13px;
  font-weight: 500;
}
.group-search-field input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(247, 199, 75, 0.14);
}
.groups-counters { margin-bottom: 10px; }
.group-item.is-hidden-by-search { display: none; }
.badge-open { color: var(--green); border-color: rgba(53,211,151,0.36); background: var(--green-soft); }
.badge-closed { color: var(--red); border-color: rgba(255,107,95,0.36); background: var(--red-soft); }
.badge-open, .badge-closed {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid;
  border-radius: 999px;
  padding: 2px 8px;
}
.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}
.field-inline input { accent-color: var(--gold); width: 16px; height: 16px; }
.grid-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.status-msg { min-height: 18px; color: var(--text-muted); font-size: 12px; margin-top: 9px; }
.status-msg.is-error { color: var(--red); }
.status-msg.is-success { color: var(--green); }

/* Shell */
.app-screen { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #0b1524 0%, #07111f 100%);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 8px; }
.sidebar-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gold-soft);
  border: 1px solid var(--border-strong);
  padding: 0;
  flex: 0 0 auto;
}
.sidebar-brand strong { font-size: 15px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 700;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-item svg { width: 16px; height: 16px; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.is-active {
  color: var(--gold);
  background: var(--gold-soft);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 700;
}
.sidebar-logout:hover { color: var(--red); border-color: rgba(255,107,95,0.38); background: var(--red-soft); }

.workspace { padding: 28px 32px 42px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h2 { font-size: 24px; letter-spacing: -0.03em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.035);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.pill-success { color: var(--green); border-color: rgba(53,211,151,0.36); background: var(--green-soft); }
.pill-danger { color: var(--red); border-color: rgba(255,107,95,0.36); background: var(--red-soft); }
.pill-warn, .pill-brand { color: var(--gold); border-color: var(--border-strong); background: var(--gold-soft); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric-card,
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 48%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metric-card { padding: 18px; }
.metric-head { display: flex; justify-content: space-between; align-items: center; }
.metric-label { color: var(--text-muted); font-size: 12px; font-weight: 700; }
.metric-value { display: block; margin-top: 12px; font-size: 29px; font-family: var(--mono); color: var(--gold); }
.metric-foot { color: var(--text-dim); font-size: 12px; }
.metric-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: var(--gold);
}
.metric-icon-green { background: var(--green-soft); color: var(--green); }
.metric-icon-red { background: var(--red-soft); color: var(--red); }
.metric-icon-amber, .metric-icon-blue { background: var(--gold-soft); color: var(--gold); }

.card { padding: 22px; margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.card-head-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.card h3 { font-size: 18px; letter-spacing: -0.02em; }
.card-sub, .hint { color: var(--text-muted); font-size: 13px; }
.groups-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 10px; }
.legend-dot:first-child { margin-left: 0; }
.legend-dot-source { background: var(--gold); }
.legend-dot-dest { background: var(--gold-soft); border: 1px solid var(--gold); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.list { display: flex; flex-direction: column; gap: 9px; max-height: 430px; overflow-y: auto; padding-right: 4px; }
.empty-state {
  color: var(--text-dim);
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
}
.group-item, .event-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(6, 14, 26, 0.55);
  padding: 13px 14px;
}
.group-item strong { display: block; font-size: 14px; color: var(--text); }
.group-item small { display: block; color: var(--text-dim); margin-top: 2px; }
.group-main { width: 100%; }
.group-source { margin-top: 8px; }
.group-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.group-title-badges { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.group-item.is-source-active { border-color: var(--gold); background: rgba(247, 199, 75, 0.06); }
.group-source-badge { flex-shrink: 0; }
.destinations {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.destinations-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.destinations-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dest-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(6, 14, 26, 0.55);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.dest-chip input { accent-color: var(--gold); width: 14px; height: 14px; }
.dest-chip.is-checked {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
}

/* Cards de instância/grupo renderizados como <button> (associar Evolution)
   precisam de reset explícito: o UA stylesheet aplica cor/appearance própria
   de <button> que ignora o "color" herdado do body, virando texto preto em
   fundo escuro se não for zerado aqui. */
.instance-pick {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.instance-pick:hover { border-color: var(--gold); background: rgba(247, 199, 75, 0.08); }
.event-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-left: 3px solid var(--gold);
}
.event-item.is-success { border-left-color: var(--green); }
.event-item.is-error { border-left-color: var(--red); }
.event-title { font-weight: 800; }
.event-meta { color: var(--text-muted); overflow-wrap: anywhere; font-size: 12px; }
.event-time { color: var(--text-dim); font-family: var(--mono); font-size: 11px; }

.fieldset {
  padding: 16px 0;
  border-top: 1px dashed var(--border);
}
.fieldset:first-of-type { border-top: 0; padding-top: 4px; }
.fieldset h4 {
  margin-bottom: 12px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
}
.qr-card .qr-body { display: grid; place-items: center; }
#qr-image { width: 240px; background: #fff; padding: 10px; border-radius: 12px; }
.workspace-foot {
  color: var(--text-dim);
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  font-size: 12px;
}

@media (max-width: 980px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-story { min-height: auto; padding: 28px; }
  .login-panel-wrap { min-height: auto; padding: 36px 24px; }
  .app-screen { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand, .sidebar-logout { flex-shrink: 0; }
  .sidebar-nav { flex-direction: row; flex: 0 0 auto; }
  .nav-item span, .sidebar-logout span { display: none; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .login-copy h1 { font-size: 34px; }
  .login-stats { grid-template-columns: 1fr; }
  .workspace { padding: 20px 12px 32px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .metrics-grid { grid-template-columns: 1fr; }
}
