/* ═══════════════════════════════════════════════════════════════
   RPF TRIAGEM — Painel Bot WhatsApp
   Paleta alinhada ao inspect-flow (tema claro profissional)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --brand-white: #ffffff;
  --brand-green: hsl(145, 28%, 26%);
  --brand-green-hover: hsl(145, 22%, 35%);
  --brand-green-soft: hsl(145, 25%, 95%);
  --brand-green-ring: hsl(145, 28%, 26%, 0.25);
  --brand-sand: var(--brand-green);
  --brand-slate: var(--text);

  --bg-deep: hsl(0, 0%, 98%);
  --bg: hsl(220, 14%, 96%);
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-hover: hsl(220, 14%, 96%);
  --border: hsl(220, 13%, 91%);
  --border-strong: hsl(220, 13%, 85%);
  --border-focus: hsl(145, 28%, 26%);
  --text: hsl(220, 15%, 14%);
  --text-muted: hsl(220, 10%, 45%);
  --accent: var(--brand-green);
  --accent-soft: var(--brand-green-soft);
  --accent-on: #ffffff;
  --wa: #25d366;
  --wa-soft: rgba(37, 211, 102, 0.12);
  --danger: hsl(0, 72%, 51%);
  --danger-soft: hsl(0, 72%, 51%, 0.1);
  --ok: hsl(142, 71%, 40%);
  --ok-soft: hsl(142, 71%, 40%, 0.12);
  --warn: hsl(38, 92%, 50%);
  --warn-soft: hsl(38, 92%, 50%, 0.12);
  --sidebar-w: 248px;
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px hsl(0 0% 0% / 0.06);
  --shadow: 0 4px 20px hsl(0 0% 0% / 0.08);
  --shadow-lg: 0 12px 40px hsl(0 0% 0% / 0.1);
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --focus-ring: 0 0 0 3px var(--brand-green-ring);
  --tr: 0.18s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ═══════ UTILITÁRIOS ═══════ */
.hidden {
  display: none !important;
}

.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;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.8125rem;
}

.hint {
  margin: 0.2rem 0 0;
  line-height: 1.4;
}

code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: hsl(220, 14%, 96%);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

/* ═══════ ANIMAÇÕES ═══════ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ═══════ SPLASH ═══════ */
.splash {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse 100% 70% at 50% 0%, rgba(201, 194, 184, 0.08), transparent), var(--bg-deep);
}

.splash.hidden {
  display: none !important;
}

.splash-card {
  text-align: center;
  padding: 2.5rem 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 24rem;
}

.splash-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  border: 3px solid var(--border-strong);
  border-top-color: var(--brand-sand);
  animation: spin .8s linear infinite;
}

.splash-msg {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.splash--error .splash-spinner {
  display: none;
}

.splash--error .splash-card {
  border-color: rgba(242, 85, 106, 0.4);
}

/* ═══════ LOGIN ═══════ */
@keyframes loginOrb1 {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -20px) scale(1.08);
  }

  66% {
    transform: translate(-15px, 15px) scale(.95);
  }
}

@keyframes loginOrb2 {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  40% {
    transform: translate(-25px, 25px) scale(1.12);
  }

  75% {
    transform: translate(20px, -10px) scale(.92);
  }
}

@keyframes loginFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes loginCardIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes loginPulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, .3);
  }

  70% {
    box-shadow: 0 0 0 16px rgba(37, 211, 102, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
  }
}

.login-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
  overflow: hidden;
}

.login-shell.hidden {
  display: none !important;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 15%, hsl(145 28% 26% / 0.08), transparent 55%),
    radial-gradient(ellipse 50% 45% at 80% 10%, hsl(145 25% 95% / 0.9), transparent 50%),
    radial-gradient(ellipse 45% 55% at 60% 85%, hsl(220 14% 96% / 0.8), transparent 55%),
    var(--bg-deep);
}

.login-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='1' cy='1' r='.5' fill='%23fff' fill-opacity='.025'/%3E%3C/svg%3E");
  pointer-events: none;
}

.login-bg::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  top: -80px;
  left: -80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 194, 184, .12) 0%, transparent 70%);
  animation: loginOrb1 18s ease-in-out infinite;
  pointer-events: none;
}

.login-orb-2 {
  position: absolute;
  width: 350px;
  height: 350px;
  bottom: -60px;
  right: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .04) 0%, transparent 70%);
  animation: loginOrb2 22s ease-in-out infinite;
  pointer-events: none;
}

.login-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 26rem;
  animation: loginCardIn .6s cubic-bezier(.16, 1, .3, 1);
}

.login-brand {
  text-align: center;
  margin-bottom: 2.25rem;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 72px;
  padding: .5rem 1rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  margin-bottom: 1.35rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .2), inset 0 1px 0 rgba(255, 255, 255, .06);
  animation: loginFloat 4s ease-in-out infinite;
  transition: transform .3s ease, box-shadow .3s ease;
}

.login-logo:hover {
  transform: scale(1.03) translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
}

.login-logo--image {
  min-width: auto;
  min-height: auto;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  animation: none;
}

.login-logo--image:hover {
  transform: none;
  box-shadow: none;
}

.login-logo .brand-logo-img {
  display: block;
  max-width: min(320px, 90vw);
  max-height: 72px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sidebar-brand-text .brand-logo-img {
  max-height: 32px;
  max-width: 150px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.login-logo .brand-symbol-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

/* Wordmark CSS (fallback se PNG não existir) */
.brand-wordmark {
  font-family: var(--font);
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

.brand-wordmark--lg {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
}

.brand-wordmark .wm-sand {
  color: var(--brand-green);
  position: relative;
}

.brand-wordmark .wm-sand::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.2em;
  height: 3px;
  border-radius: 99px;
  background: var(--brand-green);
  opacity: 0.85;
}

.brand-wordmark--sidebar {
  font-size: 1.05rem;
}

.brand-wordmark--sidebar .wm-sand::after {
  height: 2px;
  bottom: -0.15em;
}

.login-title {
  margin: 0 0 .55rem;
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--brand-sand);
}

.login-tagline {
  margin: 0 auto;
  max-width: 22rem;
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.5;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 0 0 .15rem;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.85rem;
  box-shadow: var(--shadow);
}

.login-card-heading {
  margin: 0 0 .2rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.login-form .field {
  position: relative;
}

.login-form .field:first-of-type .lbl {
  margin-top: .35rem;
}

.login-form .field .lbl {
  font-size: .78rem;
  font-weight: 600;
  color: rgba(232, 236, 240, .6);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.login-form .input {
  padding: .7rem .9rem;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  transition: all .2s ease;
}

.login-form .input:hover {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(0, 0, 0, .42);
}

.login-form .input:focus {
  border-color: var(--brand-sand);
  box-shadow: var(--focus-ring);
  background: rgba(0, 0, 0, .35);
}

.login-client-link {
  margin: 0.9rem 0 0;
  text-align: center;
}

.login-client-link a {
  color: var(--brand-green);
  font-weight: 600;
  text-decoration: none;
}

.login-client-link a:hover {
  text-decoration: underline;
}

.login-form .js-install-pwa {
  margin-top: .55rem;
  background: transparent;
  color: var(--brand-green);
  border-color: var(--brand-green);
}

.login-form .js-install-pwa:hover:not(:disabled) {
  background: var(--brand-green-soft);
  color: var(--brand-green);
  border-color: var(--brand-green);
}

.login-form .btn-primary {
  margin-top: .5rem;
  padding: .72rem 1rem;
  font-size: .92rem;
  font-weight: 600;
  background: var(--brand-green);
  border: 1px solid hsl(145 28% 22%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  letter-spacing: .01em;
  transition: all .25s ease;
}

.login-form .btn-primary:hover:not(:disabled) {
  background: hsl(145 28% 22%);
  box-shadow: 0 2px 8px rgba(48, 90, 64, .25);
  transform: translateY(-1px);
}

.login-form .btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(.98);
}

.login-foot {
  text-align: center;
  margin: 1.5rem 0 0;
  max-width: 22rem;
  margin-inline: auto;
  font-size: .78rem;
  line-height: 1.45;
}

.login-foot-icon {
  opacity: .35;
  margin-right: .25rem;
}

.login-version {
  display: inline-block;
  margin-top: .35rem;
  font-size: .68rem;
  color: rgba(110, 127, 141, .45);
  letter-spacing: .04em;
}

/* ═══════════════════════════════════════════
   LAYOUT: SIDEBAR + MAIN (APP)
   ═══════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-layout.hidden {
  display: none !important;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 8% -5%, hsl(145 28% 26% / 0.06), transparent 40%), var(--bg-deep);
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s cubic-bezier(.16, 1, .3, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-mark {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.sidebar-brand-mark .brand-symbol-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.sidebar-brand-text {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.sidebar-brand-text .brand-wordmark {
  margin: 0;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem .6rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .6rem .85rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--tr);
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: .7;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-footer {
  padding: .85rem 1rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.sidebar-api {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

.api-pill-sm {
  font-size: .7rem;
  font-weight: 500;
  padding: .15rem .45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #8ac8ff;
  word-break: break-all;
  max-width: 100%;
}

/* --- Mobile menu --- */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: .85rem;
  left: .85rem;
  z-index: 150;
  padding: .5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .main-content {
    margin-left: 0 !important;
  }
}

/* --- Main content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 1.75rem clamp(1.25rem, 4vw, 2.5rem) 3rem;
  max-width: 100%;
  min-width: 0;
}

/* ═══════ PÁGINAS ═══════ */
.page {
  display: none;
  animation: fadeIn .25s ease;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-title {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  font-weight: 800;
  letter-spacing: -.02em;
}

.page-header-actions {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.page-header-actions .btn svg {
  flex-shrink: 0;
}

/* ═══════ BOTÕES ═══════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  transition: all var(--tr);
}

.btn:active:not(:disabled) {
  transform: scale(.97);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-green);
  color: var(--accent-on);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-green-hover);
  color: var(--accent-on);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, .18);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: hsl(0 72% 51% / 0.25);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(242, 85, 106, .18);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, .04);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: .28rem .7rem;
  font-size: .76rem;
  border-radius: var(--radius-xs);
}

.btn-ic {
  font-size: .6rem;
  opacity: .85;
}

.btn .btn-loading.hidden,
.btn:not(.is-loading) .btn-loading {
  display: none;
}

.btn.is-loading .btn-label {
  display: none;
}

.btn.is-loading .btn-loading {
  display: inline;
}

/* ═══════ INPUTS ═══════ */
.lbl {
  display: block;
  margin: .85rem 0 .3rem;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field:first-child .lbl {
  margin-top: .4rem;
}

.input {
  width: 100%;
  padding: .65rem .85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .92rem;
  font-family: inherit;
  transition: all var(--tr);
}

.input::placeholder {
  color: hsl(220 10% 45% / 0.7);
}

.input:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.input:focus {
  outline: none;
  border-color: var(--brand-sand);
  box-shadow: var(--focus-ring);
  background: rgba(0, 0, 0, .45);
}

select.input {
  cursor: pointer;
}

.textarea {
  resize: vertical;
  min-height: 3rem;
  font-family: inherit;
  line-height: 1.5;
}

/* --- Toggle switch --- */
.switch-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  margin-top: 0.35rem;
  margin-bottom: 0.2rem;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch .toggle-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .05);
  transition: .3s cubic-bezier(.4, 0, .2, 1);
  border-radius: 34px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #a0b4c2;
  transition: .3s cubic-bezier(.4, 0, .2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
}

.switch .toggle-checkbox:checked+.switch-slider {
  background-color: var(--brand-sand, #e8c547);
}

.switch .toggle-checkbox:checked+.switch-slider:before {
  transform: translateX(20px);
  background-color: var(--brand-slate, #0f161c);
}

.switch .toggle-checkbox:focus-visible+.switch-slider {
  box-shadow: 0 0 0 2px rgba(232, 197, 71, 0.4);
}

.switch-label {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
}

/* ═══════ CARDS ═══════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--tr), transform .2s ease;
}

.card:hover {
  border-color: var(--border-strong);
}

.card-title {
  margin: 0 0 .65rem;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .65rem;
}

.card-head .card-title {
  margin: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: .16rem .5rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.chip--muted {
  background: rgba(255, 255, 255, .04);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ═══════ STATUS & BADGE ═══════ */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}

.action-hint {
  margin: .75rem 0 0;
  line-height: 1.4;
}

.status-block {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-label {
  font-size: .85rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: .28rem .65rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, .03);
  transition: all var(--tr);
}

.badge[data-phase="idle"] {
  border-color: rgba(110, 127, 141, .25);
  color: var(--text-muted);
}

.badge[data-phase="starting"],
.badge[data-phase="disconnecting"],
.badge[data-phase="authenticated"] {
  background: var(--accent-soft);
  border-color: rgba(201, 194, 184, .35);
  color: var(--brand-white);
}

.badge[data-phase="awaiting_qr"] {
  background: var(--warn-soft);
  border-color: rgba(240, 180, 41, .25);
  color: var(--warn);
}

.badge[data-phase="ready"] {
  background: var(--wa-soft);
  border-color: rgba(37, 211, 102, .25);
  color: #5ce496;
}

.badge[data-phase="error"] {
  background: var(--danger-soft);
  border-color: rgba(242, 85, 106, .3);
  color: #ff8f9c;
}

.health-line {
  margin: 0;
  font-size: .82rem;
}

.connected-device {
  margin-top: .85rem;
  padding: .8rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(37, 211, 102, .12);
  background: rgba(37, 211, 102, .03);
}

.connected-device.hidden {
  display: none !important;
}

.connected-device-title {
  margin: 0 0 .5rem;
  font-size: .7rem;
  font-weight: 700;
  color: #6efcb8;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.device-dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.device-dl-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: .3rem .7rem;
  align-items: baseline;
  font-size: .82rem;
}

.device-dl-row dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.device-dl-row dd {
  margin: 0;
  word-break: break-word;
}

.device-dl-row-full {
  grid-template-columns: 5.5rem 1fr;
}

.mono {
  font-family: var(--font-mono);
  font-size: .76rem;
}

.wrap {
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .device-dl-row {
    grid-template-columns: 1fr;
  }
}

/* ═══════ CALLOUTS ═══════ */
.callout {
  margin: 0;
  padding: .65rem .8rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  line-height: 1.4;
  border: 1px solid transparent;
}

.callout--error {
  background: var(--danger-soft);
  border-color: rgba(242, 85, 106, .25);
  color: #ffc4cb;
}

.callout--info {
  background: var(--accent-soft);
  border-color: rgba(201, 194, 184, .25);
  color: var(--brand-white);
}

.callout--ok {
  background: var(--ok-soft);
  border-color: rgba(61, 213, 152, .2);
  color: #9ff0d0;
}

/* ═══════ GRID & QR ═══════ */
.grid-panels {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .grid-panels {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.qr-frame {
  margin-top: .65rem;
}

.qr-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 190px;
  padding: 1.1rem;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}

.qr-img {
  width: min(250px, 75vw);
  height: auto;
  image-rendering: pixelated;
  border-radius: 4px;
}

.qr-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  color: #9ca3af;
  font-size: .84rem;
  font-weight: 500;
  pointer-events: none;
}

.qr-placeholder.hidden {
  display: none;
}

.qr-placeholder-icon {
  font-size: 1.5rem;
  opacity: .3;
}

/* ═══════ TABELAS ═══════ */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .85rem;
}

.table th {
  background: rgba(0, 0, 0, .15);
  color: var(--text-muted);
  font-weight: 600;
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--border-strong);
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .03em;
}

.table td {
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: rgba(255, 255, 255, .02);
}

.table-actions {
  display: flex;
  gap: .3rem;
  justify-content: flex-end;
}

/* ═══════ LOG ═══════ */
.card--log-full {
  padding: 0;
  overflow: hidden;
}

.log-container {
  margin: 0;
  max-height: min(44vh, 320px);
  overflow: auto;
  padding: .85rem 1rem;
  background: rgba(0, 0, 0, .45);
  font-family: var(--font-mono);
  font-size: .76rem;
  line-height: 1.5;
  color: #a0b4c2;
  border-radius: var(--radius-sm);
}

.log-container--full {
  max-height: calc(100vh - 180px);
  min-height: 400px;
  border-radius: var(--radius);
}

.log-container::-webkit-scrollbar {
  width: 6px;
}

.log-container::-webkit-scrollbar-track {
  background: transparent;
}

.log-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .08);
  border-radius: 3px;
}

.log-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, .15);
}

.log-line {
  display: flex;
  gap: .6rem;
  padding: .2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, .03);
  word-break: break-word;
}

.log-line:last-child {
  border-bottom: none;
}

.log-line--error,
.log-line--error.log-text {
  color: #ff8f9c;
}

.log-time {
  flex-shrink: 0;
  color: rgba(110, 127, 141, .6);
  font-size: .7rem;
  padding-top: .15rem;
  width: 60px;
}

.log-tag {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 0 .4rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  height: 1.4rem;
  margin-top: .05rem;
}

.log-tag-admin {
  background: rgba(232, 197, 71, 0.15);
  color: #e8c547;
  border: 1px solid rgba(232, 197, 71, 0.3);
}

.log-tag-atendimento {
  background: rgba(94, 207, 154, 0.15);
  color: #5ecf9a;
  border: 1px solid rgba(94, 207, 154, 0.3);
}

.log-tag-grupo {
  background: rgba(138, 200, 255, 0.15);
  color: #8ac8ff;
  border: 1px solid rgba(138, 200, 255, 0.3);
}

.log-tag-anexo {
  background: rgba(255, 143, 156, 0.15);
  color: #ff8f9c;
  border: 1px solid rgba(255, 143, 156, 0.3);
}

.log-tag-server,
.log-tag-api {
  background: rgba(255, 255, 255, 0.1);
  color: var(--brand-sand);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.log-text {
  flex: 1;
  overflow-wrap: anywhere;
}

/* ═══════ TOKEN LEGADO ═══════ */
.token-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .35rem;
}

.token-row .input {
  flex: 1;
  min-width: 12rem;
}

.token-status {
  margin: .5rem 0 0;
}

/* ═══════ TOAST ═══════ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: min(92vw, 420px);
  padding: .75rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .3s cubic-bezier(.16, 1, .3, 1);
}

.toast--error {
  border-color: rgba(242, 85, 106, .35);
  background: rgba(30, 10, 14, .97);
  color: #ffd0d6;
}

.toast--ok {
  border-color: rgba(61, 213, 152, .25);
  background: rgba(8, 24, 18, .97);
  color: #bff5df;
}

.toast--info {
  border-color: rgba(201, 194, 184, .35);
  background: rgba(62, 71, 96, .97);
  color: var(--brand-white);
}

.pwa-install-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .45rem;
  margin: 0 0 1rem;
}

.pwa-install-row .pwa-ios-hint {
  margin: 0;
}

.pwa-ios-hint a {
  color: inherit;
  font-weight: 600;
}

.pwa-ios-hint {
  margin: 0 0 0.5rem;
  line-height: 1.4;
  padding: 0.5rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .15);
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   CONFIGURAÇÃO DO BOT
   ═══════════════════════════════════════════ */

/* --- Form grid --- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.form-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.form-grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.form-grid .span-2 {
  grid-column: span 2;
}

@media (max-width: 600px) {

  .form-grid,
  .form-grid.cols-3,
  .form-grid.cols-4 {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: span 1;
  }
}

/* --- Tabs --- */
.msg-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  padding: .5rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-md);
  position: sticky;
  top: .5rem;
  z-index: 10;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .2);
}

.msg-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: .5rem 1rem;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
}

.msg-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .05);
}

.msg-tab.active {
  background: var(--brand-green);
  color: var(--brand-slate);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  font-weight: 700;
  transform: translateY(-1px);
}

.msg-tab-content {
  display: none;
}

.msg-tab-content.active {
  display: block;
  animation: fadeIn .2s ease;
}

.msg-field {
  margin-bottom: .8rem;
}

.msg-field .lbl {
  display: block;
  margin: 0 0 .3rem;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.msg-field .input,
.msg-field .textarea {
  width: 100%;
}

.msg-subtitle {
  font-size: .86rem;
  font-weight: 600;
  color: var(--brand-sand);
  margin: 1.25rem 0 .6rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--border);
}

/* --- Save bar --- */
.save-bar {
  position: sticky;
  bottom: .5rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  margin-top: 2rem;
  background: rgba(17, 24, 32, .9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .05);
  z-index: 10;
}

.save-status {
  color: var(--ok);
  font-weight: 600;
  font-size: .84rem;
}

/* ═══════ ITENS DE MENU DINÂMICOS ═══════ */
.menu-item-card {
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-sm);
  margin-bottom: .75rem;
  background: rgba(0, 0, 0, .15);
  transition: all var(--tr);
  overflow: hidden;
}

.menu-item-card.is-open {
  background: var(--surface-elevated);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}

.menu-item-header {
  display: flex;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: .6rem .8rem;
  background: rgba(255, 255, 255, .02);
  border-bottom: 1px solid transparent;
}

.menu-item-card.is-open>.menu-item-header {
  border-bottom-color: rgba(255, 255, 255, .05);
  background: transparent;
}

.menu-item-header-left,
.menu-item-header-right {
  display: flex;
  gap: .45rem;
  align-items: center;
  flex: 1;
  min-width: 15rem;
}

.menu-item-header-right {
  flex: 0 1 auto;
  justify-content: flex-end;
}

.btn-toggle-collapse {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .2rem;
  border-radius: 4px;
  transition: transform .2s ease, background .2s ease;
}

.btn-toggle-collapse:hover {
  background: rgba(255, 255, 255, .1);
  color: var(--text);
}

.menu-item-card:not(.is-open)>.menu-item-header .btn-toggle-collapse svg {
  transform: rotate(-90deg);
}

.menu-item-num {
  font-size: .85rem;
  color: var(--text-muted);
  padding-left: 0.1rem;
}

.menu-item-titulo {
  flex: 1;
  font-weight: 600;
  padding: .4rem .6rem;
  font-size: .88rem;
  min-width: 120px;
}

.menu-item-tag {
  font-size: .75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.2rem;
}

.menu-item-tipo {
  padding: .4rem .6rem;
  font-size: .84rem;
  max-width: 12rem;
}

.menu-item-body {
  padding: 1rem 1.25rem;
  display: none;
}

.menu-item-card.is-open>.menu-item-body {
  display: block;
  animation: fadeIn .2s ease;
}

.menu-item-subitens {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-top: .4rem;
}

/* Hierarquia & Cores */
.menu-item-card.type-resposta {
  border-left: 4px solid #5ecf9a;
}

.menu-item-card.type-submenu {
  border-left: 4px solid #8ac8ff;
}

.menu-item-card.type-triagem {
  border-left: 4px solid #e8c547;
}

.menu-item-tag.type-resposta {
  background: rgba(94, 207, 154, 0.15);
  color: #5ecf9a;
}

.menu-item-tag.type-submenu {
  background: rgba(138, 200, 255, 0.15);
  color: #8ac8ff;
}

.menu-item-tag.type-triagem {
  background: rgba(232, 197, 71, 0.15);
  color: #e8c547;
}

.menu-item-subitens>.menu-item-card {
  margin-left: 1.5rem;
  margin-top: .75rem;
}

@media (max-width: 600px) {
  .menu-item-header {
    flex-direction: column;
    align-items: stretch;
  }

  .menu-item-header-right {
    justify-content: flex-start;
  }
}

/* ═══════ TRIAGEM ═══════ */
.triagem-body .msg-field {
  margin-bottom: .55rem;
}

.tri-campo-card {
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-sm);
  margin-bottom: .75rem;
  background: rgba(0, 0, 0, .25);
  overflow: hidden;
}

.tri-campo-header {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .5rem .75rem;
  background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  flex-wrap: wrap;
}

.tri-campo-drag {
  color: rgba(255, 255, 255, .25);
  cursor: move;
  font-weight: 800;
  padding-right: 0.2rem;
  display: none;
}

.tri-campo-body {
  padding: .75rem 1rem;
}

/* ═══════ RESPONSIVO MOBILE ═══════ */
@media (max-width: 600px) {
  .main-content {
    padding: 1rem .75rem 3rem;
  }

  .card {
    padding: .9rem;
  }

  .action-bar {
    flex-direction: column;
  }

  .action-bar .btn {
    width: 100%;
  }

  .menu-item-card {
    padding: .6rem;
  }

  .menu-item-card.depth-1 {
    margin-left: .5rem;
  }

  .menu-item-card.depth-2 {
    margin-left: 1rem;
  }

  .page-title {
    font-size: 1.15rem;
  }

  .msg-tabs {
    gap: .15rem;
  }

  .msg-tab {
    padding: .3rem .55rem;
    font-size: .72rem;
  }
}

/* ═══ Dashboard — Atendimento ═══ */
.atendimento-card {
  margin-top: 1rem;
}

.atendimento-global {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.atendimento-global-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.atendimento-global-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

#atendimentoGlobalBadge[data-atendimento="pausado"] {
  background: var(--danger-soft);
  color: var(--danger);
}

#atendimentoGlobalBadge[data-atendimento="ativo"] {
  background: var(--ok-soft);
  color: var(--ok);
}

.atendimento-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.atendimento-form {
  margin-bottom: 1.25rem;
}

.atendimento-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.atendimento-form-row .input--narrow {
  width: 5rem;
  min-width: 4rem;
}

.atendimento-form-row .input:first-child {
  flex: 1;
  min-width: 10rem;
}

.atendimento-pausas-wrap,
.atendimento-ignorados-wrap,
.atendimento-eventos-wrap {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.atendimento-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.atendimento-table th,
.atendimento-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.atendimento-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.78rem;
}

.atendimento-ignorados-list,
.atendimento-eventos-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.atendimento-ignorados-list li,
.atendimento-eventos-list li {
  padding: 0.35rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.atendimento-eventos-list li {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ═══ Transmissões ═══ */
.broadcast-intro {
  margin: -0.5rem 0 1rem;
  font-size: 0.9rem;
  max-width: 42rem;
  line-height: 1.45;
}

.broadcast-lists-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.broadcast-list-card {
  padding: 0;
  overflow: hidden;
}

.broadcast-list-card.is-open {
  box-shadow: var(--shadow-sm);
}

.broadcast-list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid transparent;
}

.broadcast-list-card.is-open > .broadcast-list-header {
  border-bottom-color: var(--border);
}

.broadcast-list-header-left {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.45rem;
  min-width: 12rem;
}

.broadcast-list-header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  justify-content: flex-end;
}

.broadcast-list-header .broadcast-nome {
  flex: 1;
  min-width: 8rem;
  font-weight: 600;
}

.broadcast-list-card:not(.is-open) > .broadcast-list-header .btn-toggle-collapse svg {
  transform: rotate(-90deg);
}

.broadcast-header-summary {
  margin: 0;
  padding: 0 1rem 0.65rem 2.75rem;
  line-height: 1.4;
}

.broadcast-list-card.is-open .broadcast-header-summary {
  display: none;
}

.broadcast-list-body {
  padding: 0 1.25rem 1.1rem;
}

.broadcast-list-card:not(.is-open) .broadcast-list-body {
  display: none;
}

.broadcast-count {
  flex-shrink: 0;
}

.broadcast-numeros-wrap {
  margin-top: 0.75rem;
}

.broadcast-add-num-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.broadcast-add-num-row .broadcast-contact-name {
  flex: 0 1 11rem;
  min-width: 8rem;
}

.broadcast-add-num-row .broadcast-num-input {
  flex: 1;
  min-width: 10rem;
}

.broadcast-contact-name-cell {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.broadcast-table-container {
  margin-top: 0.75rem;
  overflow-x: auto;
}

.broadcast-numbers-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.broadcast-numbers-empty {
  text-align: center;
  padding: 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

.broadcast-numeros-wrap .input-action-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}

.broadcast-numeros-wrap .input-action-row .input {
  flex: 1;
}

.broadcast-list-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ═══ Guia de uso (guia.html) ═══ */
a.nav-item--link {
  text-decoration: none;
}

.guia-page {
  min-height: 100vh;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
}

.guia-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(37, 43, 58, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.guia-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.guia-topbar-brand img {
  height: 28px;
  width: auto;
}

.guia-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.guia-print-meta {
  display: none;
}

.guia-print-only {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 14mm 20mm;
  }

  html {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .guia-no-print,
  .guia-topbar {
    display: none !important;
  }

  .guia-print-only {
    display: block;
  }

  .guia-print-cover {
    position: relative;
    min-height: 257mm;
    box-sizing: border-box;
    page-break-after: always;
    break-after: page;
    margin: -12mm -14mm 0;
    width: calc(100% + 28mm);
  }

  .guia-print-cover-band {
    height: 28mm;
    background: linear-gradient(135deg, #3e4760 0%, #2f3648 100%);
  }

  .guia-print-cover-inner {
    padding: 18mm 16mm 12mm;
    text-align: center;
  }

  .guia-print-cover-symbol {
    width: 18mm;
    height: 18mm;
    margin-bottom: 6mm;
  }

  .guia-print-cover-logo {
    height: 10mm;
    width: auto;
    margin-bottom: 12mm;
  }

  .guia-print-cover-title {
    font-size: 22pt;
    font-weight: 700;
    color: #3e4760;
    margin: 0 0 4mm;
    line-height: 1.2;
    letter-spacing: -0.02em;
  }

  .guia-print-cover-sub {
    font-size: 11pt;
    color: #555;
    margin: 0 auto 10mm;
    max-width: 140mm;
    line-height: 1.5;
  }

  .guia-print-cover-meta {
    font-size: 9pt;
    color: #888;
    margin: 0;
    padding-top: 8mm;
    border-top: 1px solid #e0ddd8;
    display: inline-block;
    min-width: 80mm;
  }

  .guia-print-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 3mm 14mm 0;
    font-size: 7.5pt;
    color: #888;
    border-top: 1px solid #ddd;
    background: #fff;
    z-index: 9999;
  }

  .guia-page {
    background: #fff !important;
    color: #1c1f26 !important;
    min-height: auto;
    font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  }

  .guia-layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .guia-toc {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 8mm 10mm;
    margin: 0 0 8mm;
    background: #f7f6f4;
    border: 1px solid #e0ddd8;
    border-radius: 2mm;
    page-break-after: always;
    break-after: page;
  }

  .guia-toc-title {
    color: #fff;
    background: #3e4760;
    font-size: 10pt;
    margin: -8mm -10mm 6mm;
    padding: 4mm 10mm;
    border-radius: 2mm 2mm 0 0;
    letter-spacing: 0.08em;
  }

  .guia-toc nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3mm 10mm;
    counter-reset: guia-toc-item;
  }

  .guia-toc nav a {
    counter-increment: guia-toc-item;
    color: #333 !important;
    font-size: 9.5pt;
    font-weight: 500;
    padding: 2.5mm 0 2.5mm 7mm;
    position: relative;
    text-decoration: none;
    border-bottom: 1px dotted #ccc;
  }

  .guia-toc nav a::before {
    content: counter(guia-toc-item, decimal-leading-zero);
    position: absolute;
    left: 0;
    font-size: 8pt;
    font-weight: 700;
    color: #3e4760;
  }

  .guia-main {
    padding: 0 0 12mm;
  }

  .guia-hero {
    margin-bottom: 7mm;
    padding-bottom: 5mm;
    border-bottom: 1px solid #e8e6e2;
  }

  .guia-hero-title {
    display: none;
  }

  .guia-hero > p:not(.guia-print-meta) {
    color: #444 !important;
    font-size: 10.5pt;
    line-height: 1.55;
    max-width: none;
  }

  .guia-print-meta {
    display: block !important;
    font-size: 8.5pt;
    color: #888 !important;
    margin: 0 0 3mm !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .guia-section {
    scroll-margin-top: 0;
    margin-bottom: 7mm;
    break-inside: auto;
  }

  .guia-section h2 {
    font-size: 14pt;
    font-weight: 700;
    color: #fff;
    background: #3e4760;
    margin: 0 0 4mm;
    padding: 3mm 5mm;
    border: none;
    border-radius: 1.5mm;
    break-after: avoid;
    page-break-after: avoid;
  }

  .guia-section h3 {
    font-size: 10.5pt;
    font-weight: 600;
    color: #3e4760;
    margin: 4mm 0 2mm;
    padding-left: 3mm;
    border-left: 3px solid #c9c2b8;
    break-after: avoid;
  }

  .guia-section p,
  .guia-section li {
    color: #2a2d33 !important;
    font-size: 10pt;
    line-height: 1.55;
  }

  .guia-section ul,
  .guia-section ol {
    margin: 2mm 0 3mm;
  }

  .guia-card {
    background: #f7f6f4 !important;
    border: 1px solid #e0ddd8 !important;
    border-left: 4px solid #3e4760 !important;
    border-radius: 2mm;
    padding: 4mm 5mm;
    break-inside: avoid;
  }

  .guia-card strong {
    color: #3e4760;
  }

  .guia-type-grid {
    grid-template-columns: 1fr 1fr;
    gap: 3mm;
  }

  .guia-type-card {
    background: #fff !important;
    border: 1px solid #e0ddd8 !important;
    border-top: 3px solid #c9c2b8 !important;
    border-radius: 2mm;
    break-inside: avoid;
  }

  .guia-type-card strong {
    color: #3e4760;
    font-size: 9.5pt;
  }

  .guia-type-card p {
    color: #555 !important;
    font-size: 8.5pt;
    line-height: 1.45;
  }

  .guia-flow {
    background: #f0eeeb !important;
    color: #333 !important;
    border: 1px solid #ddd !important;
    border-left: 4px solid #3e4760 !important;
    font-size: 8pt;
    line-height: 1.45;
    white-space: pre-wrap;
    padding: 4mm 5mm;
    break-inside: avoid;
  }

  .guia-steps {
    margin: 3mm 0 4mm;
  }

  .guia-steps li {
    break-inside: avoid;
    margin-bottom: 3mm;
  }

  .guia-steps li::before {
    background: #3e4760 !important;
    color: #fff !important;
    width: 5mm;
    height: 5mm;
    font-size: 7pt;
    top: 0.5mm;
  }

  .guia-table-wrap {
    break-inside: avoid;
    margin: 3mm 0 4mm;
  }

  .guia-table {
    font-size: 9pt;
  }

  .guia-table thead th {
    background: #3e4760 !important;
    color: #fff !important;
    border: none !important;
    padding: 2.5mm 3mm;
    font-weight: 600;
  }

  .guia-table tbody tr:nth-child(even) td {
    background: #f7f6f4;
  }

  .guia-table th,
  .guia-table td {
    border: 1px solid #e0ddd8 !important;
    padding: 2mm 3mm;
    vertical-align: top;
  }

  .guia-foot {
    margin-top: 8mm;
    padding-top: 4mm;
    border-top: 2px solid #3e4760;
    font-size: 9pt;
    color: #666 !important;
    break-inside: avoid;
  }

  .guia-foot a {
    color: #3e4760 !important;
  }

  a[href^="#"] {
    color: inherit !important;
    text-decoration: none !important;
  }

  a[href^="http"] {
    color: #2f3648 !important;
  }

  code {
    background: #eee;
    color: #2f3648;
    padding: 0.5px 4px;
    border-radius: 2px;
    font-size: 8.5pt;
    font-family: ui-monospace, Consolas, monospace;
  }

  strong {
    font-weight: 600;
    color: #1c1f26;
  }

  .muted.small {
    color: #666 !important;
    font-size: 9pt !important;
  }

  .info-box {
    background: #f0eeeb !important;
    border: 1px solid #e0ddd8 !important;
  }
}

.guia-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

@media (max-width: 900px) {
  .guia-layout {
    grid-template-columns: 1fr;
  }

  .guia-toc {
    position: static !important;
    max-height: none !important;
    margin-bottom: 1rem;
  }
}

.guia-toc {
  position: sticky;
  top: 4.5rem;
  align-self: start;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  padding: 1.25rem 0.75rem 1rem 0;
}

.guia-toc-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.65rem 0.5rem;
}

.guia-toc nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.guia-toc a {
  display: block;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.35;
  transition: background var(--tr), color var(--tr);
}

.guia-toc a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.guia-main {
  padding: 1.5rem 0 2rem;
  min-width: 0;
}

.guia-hero {
  margin-bottom: 2rem;
}

.guia-hero h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  margin: 0 0 0.5rem;
  line-height: 1.25;
}

.guia-hero p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 42rem;
}

.guia-section {
  scroll-margin-top: 5rem;
  margin-bottom: 2.25rem;
}

.guia-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.guia-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--accent);
}

.guia-section p,
.guia-section li {
  font-size: 0.9rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.88);
}

.guia-section ul,
.guia-section ol {
  margin: 0.5rem 0 1rem;
  padding-left: 1.25rem;
}

.guia-section li {
  margin-bottom: 0.35rem;
}

.guia-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 0.75rem 0 1rem;
}

.guia-steps {
  counter-reset: guia-step;
  list-style: none;
  padding-left: 0;
  margin: 0.75rem 0 1rem;
}

.guia-steps li {
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: 0.85rem;
  counter-increment: guia-step;
}

.guia-steps li::before {
  content: counter(guia-step);
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guia-flow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.guia-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

.guia-type-card {
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
}

.guia-type-card strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.guia-type-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.guia-table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0 1rem;
}

.guia-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.guia-table th,
.guia-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.guia-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.guia-foot {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Integração RPF Triagem */
.brand-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.brand-stack-title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--text);
}

.brand-stack-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.inspect-flow-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  margin-bottom: 0.75rem;
}

.inspect-flow-status[data-connected="true"] {
  border-color: hsl(142 71% 40% / 0.35);
  background: var(--ok-soft);
}

.inspect-flow-status[data-connected="false"] {
  border-color: hsl(0 72% 51% / 0.25);
  background: var(--danger-soft);
}

.inspect-flow-status-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.inspect-flow-status-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.login-brand-title {
  margin: 0.75rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.login-brand-sub {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card--intro {
  border-style: dashed;
}

.integration-list {
  margin: 0;
  padding-left: 1.15rem;
  line-height: 1.65;
}

.integration-list code {
  font-size: 0.82em;
}

/* ═══════ ENVIO PAUSE + KPI + HISTÓRICO ═══════ */
.page-header-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.badge-envio[data-envio="ativo"] {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-envio[data-envio="pausado"] {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.card--envio-pause {
  border-color: rgba(48, 90, 64, 0.2);
  background: linear-gradient(135deg, rgba(48, 90, 64, 0.04), transparent);
}

.envio-pause-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-title--sm {
  font-size: 1rem;
  margin-bottom: 0;
}

.btn-envio-toggle {
  min-width: 10rem;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  border: none;
}

.btn-envio-toggle--pausado {
  background: #d97706;
}

.btn-envio-toggle--pausado:hover:not(:disabled) {
  background: #b45309;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

@media (max-width: 720px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.kpi-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  background: var(--surface);
}

.kpi-card--wide {
  grid-column: span 2;
}

@media (max-width: 720px) {
  .kpi-card--wide {
    grid-column: span 2;
  }
}

.kpi-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-value--warn {
  color: #b45309;
}

.kpi-value--sm {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
}

.envios-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chip-filter {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}

.chip-filter.active {
  background: rgba(48, 90, 64, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

.card--envios-table {
  padding: 0;
  overflow: hidden;
}

.envios-table-wrap {
  overflow-x: auto;
}

.envios-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.envios-table th,
.envios-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.envios-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-muted, rgba(0, 0, 0, 0.02));
}

.envios-empty {
  text-align: center;
  padding: 2rem !important;
}

.envios-td-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.envios-td-tel {
  font-family: var(--font-mono, monospace);
}

.chip-origem--auto {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.chip-origem--manual {
  background: rgba(107, 114, 128, 0.12);
  color: #374151;
}

.chip-origem--teste {
  background: rgba(168, 85, 247, 0.12);
  color: #7e22ce;
}

.envio-status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.envio-status--ok {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
}

.envio-status--err {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.envio-status--pause {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.toast--success {
  background: #047857;
  color: #fff;
}