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

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --green: #008571;
  --green-dim: #014d49;
  --amber: #e6a23c;
  --red: #e85d5d;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, sans-serif;
  --sidebar-w: 240px;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green-dim), var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.95rem;
}

.sidebar-brand small {
  color: var(--muted);
  font-size: 0.72rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(0, 133, 113, 0.18);
  color: #5eead4;
  font-weight: 600;
}

.nav-icon {
  font-size: 0.9rem;
  width: 1.25rem;
  text-align: center;
}

.sidebar-foot {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.sidebar-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.sidebar-status.connected .dot { background: #4ade80; }
.sidebar-status.connected { color: #5eead4; }
.sidebar-status.qr .dot { background: var(--amber); }
.sidebar-status.qr { color: #f5d08a; }
.sidebar-status.disconnected .dot { background: var(--red); }

.content-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: linear-gradient(135deg, var(--green-dim), var(--green));
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  flex-shrink: 0;
}

.menu-bar {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

body.drawer-open .menu-toggle .menu-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.drawer-open .menu-toggle .menu-bar:nth-child(2) {
  opacity: 0;
}

body.drawer-open .menu-toggle .menu-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.topbar-titles {
  flex: 1;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar p {
  margin: 0.1rem 0 0;
  font-size: 0.82rem;
  opacity: 0.9;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.25);
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.badge.connected .dot { background: #4ade80; }
.badge.qr .dot { background: var(--amber); }
.badge.disconnected .dot { background: var(--red); }

/* ── Views ── */
.views {
  flex: 1;
  padding: 1.5rem;
  max-width: 960px;
  min-height: 0;
  overflow-y: auto;
}

.views:has(#view-inbox.active) {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.views.views-wide,
.views:has(#view-inbox.active),
.views:has(#view-remarketing.active),
.views:has(#view-labels.active) {
  max-width: none;
  width: 100%;
}

.view {
  display: none;
  animation: fadeIn 0.2s ease;
}

.view.active {
  display: block;
}

#view-inbox.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.view-intro {
  margin: 0 0 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.card .sub {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 0.15rem;
}

.stat-hint {
  font-size: 0.72rem;
  color: var(--muted);
}

.flow-list {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.flow-list li {
  margin-bottom: 0.45rem;
}

.flow-list li::marker {
  color: var(--green);
}

/* ── Conexão ── */
.conn-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.method-card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.method-card .btn-block {
  margin-top: auto;
}

.qr-preview {
  flex: 1;
  min-height: 200px;
  background: #fff;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  padding: 1rem;
}

.qr-preview img {
  max-width: 220px;
  height: auto;
}

.qr-placeholder {
  color: #888;
  font-size: 0.85rem;
  margin: 0;
  text-align: center;
  padding: 0 0.5rem;
}

.qr-hint {
  margin-top: -0.5rem !important;
  color: #5eead4 !important;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 1.25rem;
  background: #fff;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.qr-wrap img {
  max-width: 240px;
  height: auto;
}

.conn-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.conn-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  flex-shrink: 0;
}

.conn-avatar.connected {
  background: rgba(0, 133, 113, 0.25);
  color: #5eead4;
  border: 2px solid var(--green);
}

.connected-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.connected-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.connected-number {
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.pairing-box {
  text-align: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.pairing-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.pairing-code {
  display: inline-block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--green-dim);
  background: #fff;
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
}

/* ── Formulários ── */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

input[type='text'],
input[type='tel'],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field {
  margin-bottom: 0.85rem;
}

.btn {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

/* ── Cenários ── */
.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.view-intro-compact {
  font-size: 0.78rem;
  margin-bottom: 1rem;
}

.view-intro-compact code {
  font-size: 0.72rem;
}

/* Accordion cenários */
.scenario-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  overflow: hidden;
}

.scenario-item[open] {
  border-color: rgba(0, 133, 113, 0.55);
  box-shadow: 0 0 0 1px rgba(0, 133, 113, 0.2);
}

.scenario-item.active {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(0, 133, 113, 0.45);
}

.scenario-item > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  user-select: none;
}

.scenario-item > summary::-webkit-details-marker {
  display: none;
}

.scenario-item > summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.scenario-title {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.scenario-id {
  font-size: 0.68rem;
  color: var(--muted);
  font-family: monospace;
  padding: 0.15rem 0.4rem;
  background: var(--surface);
  border-radius: 4px;
  flex-shrink: 0;
}

.scenario-chevron {
  color: var(--muted);
  font-size: 1.1rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.scenario-item[open] > summary .scenario-chevron {
  transform: rotate(90deg);
}

.scenario-body {
  padding: 0 0.85rem 0.85rem;
  border-top: 1px solid var(--border);
}

.scenario-body p.desc {
  margin: 0.65rem 0 0.75rem;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.45;
}

.scenario-item header {
  display: none;
}

.label-optional {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--muted);
}

.char-count {
  float: right;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.msg-builder {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.msg-section label {
  display: block;
  margin-bottom: 0.35rem;
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
}

.header-type-picker {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.header-type-btn {
  width: 42px;
  height: 42px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.header-type-btn:hover {
  border-color: rgba(0, 133, 113, 0.45);
}

.header-type-btn.active {
  border-style: solid;
  border-color: var(--green);
  background: rgba(0, 133, 113, 0.12);
}

.header-fields {
  margin-top: 0.35rem;
}

.header-fields input {
  width: 100%;
}

.button-fields {
  margin-top: 0.15rem;
}

.button-fields input,
.msg-section select,
.msg-section textarea {
  width: 100%;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.sticky-actions {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 0;
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--bg) 30%);
}

/* ── Cenários: layout editor + fluxograma ── */
.scenarios-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 1rem;
  align-items: start;
}

.scenarios-main {
  min-width: 0;
}

.scenario-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.scenario-tab {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.scenario-tab:hover {
  color: var(--text);
}

.scenario-tab.active {
  background: rgba(0, 133, 113, 0.15);
  border-color: rgba(0, 133, 113, 0.55);
  color: var(--green);
}

.scenario-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.meta-tag {
  font-size: 0.68rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.scenario-item-conv .scenario-id {
  color: var(--green);
}

.scenarios-flow-panel {
  position: sticky;
  top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.85rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.flow-panel-head h2 {
  margin: 0 0 0.15rem;
  font-size: 0.9rem;
}

.flow-panel-head .sub {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
}

.flow-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.flow-node {
  width: 100%;
  text-align: center;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
}

.flow-start,
.flow-end {
  background: rgba(0, 133, 113, 0.12);
  border: 1px solid rgba(0, 133, 113, 0.35);
  color: var(--green);
}

.flow-decision {
  background: rgba(255, 193, 7, 0.08);
  border: 1px solid rgba(255, 193, 7, 0.35);
  color: #e6b800;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  padding: 1rem 0.5rem;
}

.flow-process {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}

.flow-connector {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
}

.flow-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
}

.flow-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.flow-branch-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.flow-tags {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
}

.flow-tags-wrap {
  flex-wrap: wrap;
}

.flow-tag {
  font-size: 0.62rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, color 0.15s;
}

.flow-tag:hover,
.flow-tag.active {
  border-color: var(--green);
  color: var(--green);
}

.flow-tag-conv {
  font-family: monospace;
}

.flow-tag-more {
  font-size: 0.62rem;
  color: var(--muted);
  padding: 0.2rem;
}

.flow-scenario-detail {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.flow-detail-empty {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.flow-detail-title {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
}

.flow-detail-id code {
  font-size: 0.68rem;
  color: var(--muted);
}

.flow-detail-trigger,
.flow-detail-example,
.flow-detail-state,
.flow-detail-desc {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.35rem 0;
  line-height: 1.4;
}

.flow-detail-preview {
  margin-top: 0.65rem;
}

.flow-detail-label {
  font-size: 0.68rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.35rem;
}

.flow-preview-bubble {
  background: #005c4b;
  color: #e9edef;
  padding: 0.5rem 0.65rem;
  border-radius: 8px 8px 8px 2px;
  font-size: 0.72rem;
  line-height: 1.45;
}

.flow-preview-bubble .wa-btn-link {
  margin-top: 0.35rem;
  width: 100%;
}

.flow-detail-vars {
  font-size: 0.68rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

@media (max-width: 1100px) {
  .scenarios-layout {
    grid-template-columns: 1fr;
  }

  .scenarios-flow-panel {
    position: static;
    max-height: none;
  }
}

/* ── Cenários + Visualizar ── */
.visualize-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 1rem;
  align-items: stretch;
  min-height: calc(100vh - 8.25rem);
}

.visualize-compose-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.7rem;
  min-width: 0;
  max-height: calc(100vh - 8.25rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.visualize-compose-head {
  margin-bottom: 0.45rem;
  flex-shrink: 0;
}

.visualize-compose-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
}

.visualize-compose-sub {
  margin: 0.15rem 0 0;
  font-size: 0.64rem;
  color: var(--muted);
  line-height: 1.4;
}

.visualize-compose-panel .field {
  margin-bottom: 0.42rem;
}

.visualize-compose-panel label {
  margin-bottom: 0.22rem;
  font-size: 0.68rem;
}

.visualize-compose-panel input[type='text'],
.visualize-compose-panel select,
.visualize-compose-panel textarea {
  padding: 0.43rem 0.55rem;
  border-radius: 7px;
  font-size: 0.76rem;
}

.visualize-compose-panel textarea[data-field='message'] {
  height: clamp(150px, 29vh, 230px);
  min-height: 150px;
  resize: none;
}

.visualize-compose-panel .msg-builder {
  flex: 1;
  min-height: 0;
  margin-top: 0.45rem;
  gap: 0;
  overflow-y: auto;
}

.visualize-compose-panel .msg-section {
  margin-bottom: 0;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.visualize-compose-panel .msg-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.visualize-compose-panel .msg-section label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.visualize-compose-panel .msg-section label .label-optional {
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  opacity: 0.7;
}

.visualize-compose-panel .msg-section label .char-count {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.visualize-compose-panel .header-type-picker {
  gap: 0.35rem;
}

.visualize-compose-panel .header-type-btn {
  width: 34px;
  height: 34px;
  border-width: 1px;
  border-radius: 7px;
  font-size: 0.72rem;
}

.visualize-compose-panel .header-fields {
  margin-top: 0.3rem;
}

.visualize-compose-panel .field-hint {
  margin-top: 0.25rem;
  font-size: 0.6rem;
  line-height: 1.2;
}

/* ── Picker tipo de botão ── */
.btn-type-picker {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 0;
}

.btn-type-btn {
  flex: 1;
  padding: 0.38rem 0.3rem;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.68rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.btn-type-btn:last-child {
  border-right: none;
}

.btn-type-btn:hover {
  background: rgba(0, 133, 113, 0.08);
  color: var(--text);
}

.btn-type-btn.active {
  background: rgba(0, 133, 113, 0.18);
  color: var(--green);
  font-weight: 600;
}

/* Corrige: display:grid sobrepõe atributo hidden nativo */
.button-fields[hidden],
.header-fields[hidden] {
  display: none !important;
}

.visualize-compose-panel .button-fields {
  margin-top: 0.4rem;
}

/* 3 botões rápidos lado a lado */
.visualize-compose-panel .button-fields[data-button-fields="quick"] {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

/* CTA: título + url empilhados */
.visualize-compose-panel .button-fields[data-button-fields="cta"] {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.visualize-actions {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: none;
}

.visualize-actions .btn {
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
}

.btn-goto-visualize {
  margin-top: 0.65rem;
}

.scenarios-editor {
  min-width: 0;
}

.wa-preview-panel {
  position: sticky;
  top: 0.75rem;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
  max-height: calc(100vh - 8.25rem);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.wa-preview-controls {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.65rem;
  flex-shrink: 0;
}

.wa-preview-head {
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.wa-preview-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.wa-preview-scenario {
  margin: 0.15rem 0 0;
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.35;
}

.wa-preview-hint {
  margin: 0.42rem 0 0;
  font-size: 0.6rem;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
  flex-shrink: 0;
}

.wa-preview-hint code {
  font-size: 0.65rem;
}

.wa-preview-switch {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
}

.wa-preview-tab {
  flex: 1;
  border: none;
  border-radius: 7px;
  padding: 0.38rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.wa-preview-tab:hover {
  color: var(--text);
}

.wa-preview-tab.active {
  background: var(--green);
  color: #fff;
}

.wa-preview-phone {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  padding: 0.85rem 0 0.85rem;
}

.wa-preview-phone .iphone-shell {
  width: 100%;
  max-width: 295px;
}

.wa-preview-phone .iphone-shell-inner {
  height: clamp(490px, calc(100vh - 15.5rem), 620px);
  display: flex;
  flex-direction: column;
}

.wa-preview-phone .wa-phone {
  flex: 1;
  min-height: 0;
}

.wa-preview-phone .wa-phone-chat {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.wa-bubble-header-text {
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

.wa-bubble-header-media {
  margin: -5px -9px 0.4rem;
  overflow: hidden;
  border-radius: 6px 6px 0 0;
  background: #111b21;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-bubble-header-media img {
  width: 100%;
  display: block;
  max-height: 110px;
  object-fit: cover;
}

.wa-media-placeholder {
  font-size: 0.72rem;
  color: #8696a0;
  padding: 0.5rem;
}

.wa-bubble-header-doc {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0 0.4rem;
  margin-bottom: 0.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.wa-doc-icon {
  font-size: 1.1rem;
}

.wa-doc-name {
  font-size: 0.72rem;
  font-weight: 600;
  word-break: break-all;
}

.wa-bubble-footer {
  font-size: 0.65rem;
  color: #8696a0;
  margin-top: 0.2rem;
  line-height: 1.3;
  clear: both;
}

.wa-bubble:has(.wa-bubble-header-media) {
  padding-top: 0;
}

.wa-phone-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.45rem;
  text-align: center;
}

/* ── Moldura iPhone ── */
.device-frame {
  border-radius: 26px;
  padding: 8px 7px 10px;
  background: #0e0f11;
  border: 2px solid #3d3d42;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* Shell externo — borda metálica fina, fundo completamente preto */
.iphone-shell {
  position: relative;
  border-radius: 44px;
  padding: 2px;
  background: linear-gradient(145deg, #606368 0%, #2a2c30 40%, #1a1b1e 60%, #4a4d52 100%);
  box-shadow:
    0 24px 52px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(0, 0, 0, 0.8);
}

/* Botões físicos laterais */
.iphone-shell::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 110px;
  width: 2px;
  height: 68px;
  border-radius: 2px 0 0 2px;
  background: linear-gradient(180deg, #4a4d52, #2a2c30);
}

.iphone-shell::after {
  content: '';
  position: absolute;
  right: -2px;
  top: 130px;
  width: 2px;
  height: 82px;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(180deg, #4a4d52, #2a2c30);
}

/* Bezel interno preto */
.iphone-shell-inner {
  border-radius: 42px;
  overflow: hidden;
  background: #000;
}

/* Tela — sem raio próprio, herda do inner */
.wa-phone {
  display: flex;
  flex-direction: column;
  background: #0b141a;
  overflow: hidden;
}

/* Status bar integrada no topo da tela */
.iphone-statusbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 20px;
  background: #075e54;
  position: relative;
  flex-shrink: 0;
}

.isb-time {
  font-size: 0.65rem;
  font-weight: 700;
  color: #e9edef;
  letter-spacing: 0.01em;
  min-width: 28px;
}

.isb-island {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 78px;
  height: 22px;
  background: #000;
  border-radius: 999px;
}

.isb-signal {
  font-size: 0.55rem;
  font-weight: 700;
  color: #e9edef;
  letter-spacing: 0.02em;
  text-align: right;
  min-width: 28px;
}

/* Header WhatsApp */
.wa-phone-top {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  height: 52px;
  padding: 0 0.6rem 0 0.5rem;
  background: #075e54;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.wa-phone-back {
  color: #e9edef;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  margin-right: -0.1rem;
}

.wa-phone-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #008571, #014d49);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-phone-avatar-user {
  background: linear-gradient(135deg, #6b5b95, #4a4063);
}

.wa-phone-contact {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.wa-phone-contact strong {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e9edef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-phone-contact span {
  font-size: 0.6rem;
  color: rgba(233, 237, 239, 0.78);
}

.wa-phone-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #e9edef;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}

.iphone-home-indicator {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b141a;
  flex-shrink: 0;
}

.iphone-home-indicator::after {
  content: '';
  width: 96px;
  height: 3px;
  border-radius: 999px;
  background: rgba(233, 237, 239, 0.55);
}

.wa-phone-chat {
  padding: 0.5rem 0.5rem 0.5rem;
  background-color: #0b141a;
  background-image: url('/assets/wa-wallpaper.png');
  background-size: cover;
  background-position: center;
}

.wa-chat-flow {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

/* Grupo de mensagens do mesmo lado */
.wa-inbound-group {
  align-self: flex-start;
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0.45rem;
}

.wa-outbound-group {
  align-self: flex-end;
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0.45rem;
}

/* Bolha base */
.wa-bubble {
  max-width: 100%;
  padding: 5px 9px 4px 9px;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.25);
  position: relative;
}

.wa-bubble-out {
  align-self: flex-end;
  border-radius: 7.5px 7.5px 2px 7.5px;
  background: #005c4b;
  color: #e9edef;
}

.wa-bubble-in {
  align-self: flex-start;
  border-radius: 7.5px 7.5px 7.5px 2px;
  background: #202c33;
  color: #e9edef;
}

.wa-bubble-sm {
  max-width: 65%;
}

.wa-bubble-text {
  font-size: 0.82rem;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-bubble-text strong {
  font-weight: 700;
}

.wa-bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.18rem;
  margin-top: 2px;
  margin-left: 0.5rem;
  float: right;
  padding-left: 0.35rem;
  padding-top: 0.2rem;
}

.wa-bubble-time {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}

.wa-bubble-out .wa-bubble-time {
  color: rgba(233, 237, 239, 0.6);
}

.wa-bubble-in .wa-bubble-time {
  color: #8696a0;
}

.wa-bubble-ticks {
  font-size: 0.62rem;
  color: #53bdeb;
  letter-spacing: -0.06em;
}

/* ── Card interativo (mensagem + botão conectados) ── */
.wa-inbound-group:has(.wa-interactive) > .wa-bubble-in,
.wa-outbound-group:has(.wa-interactive) > .wa-bubble-out {
  width: 100%;
  max-width: 100%;
}

.wa-inbound-group > .wa-bubble-in:has(+ .wa-interactive) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.wa-outbound-group > .wa-bubble-out:has(+ .wa-interactive) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.wa-interactive {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #2a3942;
  background: #1f2c34;
  width: 100%;
}

.wa-inbound-group > .wa-bubble-in + .wa-interactive {
  border-top: none;
  border-radius: 0 0 7.5px 7.5px;
}

.wa-outbound-group > .wa-bubble-out + .wa-interactive {
  border-top: none;
  border-radius: 0 0 2px 7.5px;
  background: #004c3f;
  border-color: rgba(0, 0, 0, 0.15);
}

/* Standalone (sem bolha acima) */
.wa-interactive {
  border-radius: 7.5px;
}

.wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  width: 100%;
  padding: 0.42rem 0.5rem;
  border: none;
  border-top: 1px solid #2a3942;
  background: transparent;
  color: #53bdeb;
  font-size: 0.74rem;
  font-weight: 500;
  font-family: inherit;
  cursor: default;
}

.wa-interactive .wa-btn:first-child {
  border-top: none;
}

.wa-btn-link::before {
  content: '↗';
  font-size: 0.85em;
  opacity: 0.85;
  margin-right: 0.2rem;
}

.wa-phone-input {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.5rem 0.45rem;
  background: #0b141a;
  flex-shrink: 0;
}

.wa-input-emoji {
  font-size: 1rem;
  opacity: 0.72;
  flex-shrink: 0;
  color: #aebac1;
}

.wa-input-pill {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.38rem;
  background: #1f2c34;
  border-radius: 999px;
  padding: 0.42rem 0.58rem;
  height: 36px;
}

.wa-input-field {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  color: #8696a0;
  white-space: nowrap;
  overflow: hidden;
}

.wa-input-attach,
.wa-input-camera {
  color: #aebac1;
  font-size: 0.88rem;
  opacity: 0.9;
  flex-shrink: 0;
}

.wa-input-mic {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

@media (max-width: 1100px) {
  .visualize-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .visualize-compose-panel {
    max-height: none;
  }

  .wa-preview-panel {
    position: static;
    max-height: none;
  }

  .wa-preview-phone .iphone-shell {
    max-width: 280px;
  }

  .wa-preview-phone .iphone-shell-inner {
    height: 540px;
  }
}

@media (max-width: 560px) {
  .wa-preview-phone .iphone-shell {
    max-width: 260px;
  }

  .wa-preview-phone .iphone-shell-inner {
    height: 500px;
  }
}

@media (max-height: 820px) and (min-width: 1101px) {
  .visualize-layout {
    min-height: calc(100vh - 7.4rem);
  }

  .visualize-compose-panel,
  .wa-preview-panel {
    max-height: calc(100vh - 7.4rem);
  }

  .wa-preview-phone .iphone-shell {
    max-width: 272px;
  }

  .wa-preview-phone .iphone-shell-inner {
    height: clamp(430px, calc(100vh - 15rem), 510px);
  }
}

@media (max-height: 720px) {
  .wa-preview-panel {
    max-height: calc(100vh - 6.6rem);
  }

  .wa-preview-phone .iphone-shell {
    max-width: 250px;
  }

  .wa-preview-phone .iphone-shell-inner {
    height: clamp(390px, calc(100vh - 14.5rem), 450px);
  }
}

/* ── Simulador ── */
.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.sim-scenario-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.anti-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.risk-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.risk-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

.risk-item .level {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.risk-item .level.high { background: rgba(232, 93, 93, 0.25); color: #f0a0a0; }
.risk-item .level.medium { background: rgba(230, 162, 60, 0.2); color: #f5d08a; }
.risk-item .level.low { background: rgba(0, 133, 113, 0.2); color: #5eead4; }

.blocked-list {
  font-size: 0.8rem;
  color: var(--muted);
}

.blocked-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

/* ── Log ── */
.card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-toolbar h2 {
  margin: 0;
}

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

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.log-table th,
.log-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.log-table th {
  color: var(--muted);
  font-weight: 600;
}

.empty-cell {
  color: var(--muted);
  text-align: center !important;
  padding: 1.5rem !important;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: monospace;
}

.tag.ok { background: rgba(0, 133, 113, 0.25); color: #5eead4; }
.tag.pending { background: rgba(100, 149, 237, 0.2); color: #93c5fd; }
.tag.warn { background: rgba(230, 162, 60, 0.2); color: var(--amber); }
.tag.err { background: rgba(232, 93, 93, 0.2); color: var(--red); }

.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.alert.warn {
  background: rgba(230, 162, 60, 0.15);
  border: 1px solid rgba(230, 162, 60, 0.35);
  color: #f5d08a;
}

.saved-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--green);
  color: #fff;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 100;
}

.saved-toast.show { opacity: 1; }

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 150;
  backdrop-filter: blur(2px);
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .topbar {
    flex-wrap: nowrap;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
  }

  .topbar h1 {
    font-size: 1rem;
  }

  .topbar p {
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .badge {
    font-size: 0.72rem;
    padding: 0.3rem 0.6rem;
    flex-shrink: 0;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(280px, 85vw);
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }

  body.drawer-open .sidebar {
    transform: translateX(0);
  }

  body.drawer-open .mobile-overlay {
    display: block;
  }

  .sidebar-nav {
    flex-direction: column;
    overflow-x: visible;
    padding: 0.75rem 0.5rem;
    gap: 0.2rem;
  }

  .nav-item {
    white-space: normal;
    font-size: 0.88rem;
    padding: 0.7rem 0.85rem;
  }

  .sidebar-foot {
    display: block;
  }

  .content-wrap {
    width: 100%;
  }

  .views {
    padding: 1rem;
    max-width: none;
  }
}

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.login-title {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.login-sub {
  margin: 0 0 1.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.login-form .field {
  margin-bottom: 0.85rem;
}

.login-error {
  color: var(--red);
  font-size: 0.8rem;
  margin: 0 0 0.75rem;
}

.btn-logout {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
}

.btn-logout:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* ── Inbox / Conversas ── */
#view-inbox.view.active {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  max-width: none;
  min-height: 0;
  overflow: hidden;
}

.inbox-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--border);
}

.inbox-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
}

.inbox-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.inbox-sidebar-head h2 {
  margin: 0;
  font-size: 0.95rem;
}

.inbox-list-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.inbox-list-tab {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.inbox-list-tab:hover {
  color: var(--text);
  border-color: var(--muted);
}

.inbox-list-tab.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--text);
}

.inbox-thread-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.inbox-empty-hint {
  padding: 1rem;
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.inbox-thread {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.inbox-thread:hover {
  background: rgba(255, 255, 255, 0.03);
}

.inbox-thread.active {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid var(--accent);
}

.inbox-thread-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.inbox-thread-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.inbox-thread-name strong {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bolinha de status do bot ao lado do nome */
.inbox-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.inbox-dot--on {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.inbox-dot--off {
  background: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.18);
}

/* Marcador do funil (status de pagamento) */
.inbox-funnel {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.inbox-funnel--awaiting {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.25);
}

.inbox-funnel--pending {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}

.inbox-funnel--paid {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.3);
}

.inbox-thread-time {
  font-size: 0.68rem;
  color: var(--muted);
  flex-shrink: 0;
}

.inbox-thread-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.inbox-thread-sub {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.inbox-thread-preview {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.inbox-thread-phone {
  font-size: 0.68rem;
  color: var(--muted);
}

.inbox-archived-tag {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.inbox-unread {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.inbox-tag-manual {
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  flex-shrink: 0;
}

.inbox-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

.inbox-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.inbox-placeholder[hidden] {
  display: none !important;
}

.inbox-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
}

.inbox-chat[hidden] {
  display: none !important;
}

/* ===== Inbox: conversa estilo WhatsApp Web ===== */

/* Cabeçalho da conversa */
.icv-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.icv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--green-dim), var(--green));
}

.icv-ident {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.icv-ident strong {
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icv-phone {
  font-size: 0.74rem;
  color: var(--muted);
}

.icv-meta {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icv-head .ibot {
  flex-shrink: 0;
}

.icv-head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
}

.inbox-conv-menu {
  position: relative;
}

.inbox-menu-btn {
  min-width: 2rem;
  padding: 0.25rem 0.45rem;
  font-size: 1.1rem;
  line-height: 1;
}

.inbox-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  min-width: 11rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.inbox-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
}

.inbox-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.inbox-menu-item--danger {
  color: #f87171;
}

.inbox-menu-item--danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

/* Toggle do bot — bem visível */
.ibot {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.7rem 0.3rem 0.45rem;
  border-radius: 999px;
  background: rgba(0, 133, 113, 0.16);
  border: 1px solid var(--green);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.ibot input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ibot-track {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: var(--green);
  flex-shrink: 0;
  transition: background 0.18s;
}

.ibot-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s;
}

.ibot input:checked + .ibot-track .ibot-thumb {
  transform: translateX(16px);
}

.ibot-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: #5eead4;
  white-space: nowrap;
}

.ibot.ibot-off {
  background: rgba(232, 93, 93, 0.12);
  border-color: var(--red);
}

.ibot.ibot-off .ibot-track {
  background: #5b6677;
}

.ibot.ibot-off .ibot-text {
  color: #f0a6a6;
}

/* Corpo das mensagens */
.icv-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.5rem 1.25rem;
  background: var(--bg);
  background-image: radial-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 0);
  background-size: 18px 18px;
}

.icv-empty {
  margin: auto;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.icv-row {
  display: flex;
}

.icv-row-in {
  justify-content: flex-start;
}

.icv-row-out {
  justify-content: flex-end;
}

.icv-bubble {
  max-width: min(72%, 520px);
  padding: 0.45rem 0.65rem 0.3rem;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.icv-row-in .icv-bubble {
  background: var(--surface2);
  border-top-left-radius: 3px;
  color: var(--text);
}

.icv-row-out .icv-bubble {
  background: var(--green-dim);
  border-top-right-radius: 3px;
  color: #eafff8;
}

.icv-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.icv-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 0.15rem;
  font-size: 0.64rem;
  color: rgba(255, 255, 255, 0.5);
}

.icv-ticks {
  color: #53bdeb;
}

.icv-bubble-btns {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.icv-bubble-btn {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #53bdeb;
  padding: 0.3rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

/* Layout dividido: conversa (esquerda) | envio (direita) */
.icv-split {
  display: flex;
  flex: 1;
  min-height: 0;
}

.icv-side {
  width: clamp(360px, 46%, 520px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

/* Pré-visualização no topo da lateral */
.icv-preview {
  flex-shrink: 0;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.icv-side-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.icv-preview-area {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  border-radius: 8px;
  padding: 0.6rem;
  border: 1px solid var(--border);
  background-color: var(--bg);
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 0);
  background-size: 16px 16px;
  min-height: clamp(150px, 22vh, 240px);
  max-height: 40vh;
  overflow-y: auto;
}

.icv-preview-area .icv-preview-empty {
  margin: auto;
}

.icv-preview-area .icv-bubble {
  max-width: 100%;
}

.icv-preview-empty {
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
}

.icv-bubble-footer {
  margin-top: 0.3rem;
  font-size: 0.66rem;
  font-style: italic;
  color: rgba(255, 255, 255, 0.5);
}

.icv-locked {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--muted);
}

.icv-locked[hidden] {
  display: none !important;
}

.icv-locked-ico {
  font-size: 1.6rem;
}

.icv-locked p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.icv-compose {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.icv-compose[hidden] {
  display: none !important;
}

.icv-compose-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem 0.85rem 0.85rem;
}

.icv-compose-opts {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.inbox-label-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem 0.55rem;
  background: rgba(99, 102, 241, 0.06);
}

.inbox-label-summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}

.inbox-label-summary::-webkit-details-marker {
  display: none;
}

.inbox-label-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.inbox-label-hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
}

.inbox-label-status {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.inbox-label-preview-wrap {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #111;
}

.inbox-label-preview-img {
  display: block;
  width: 100%;
  height: auto;
}

.inbox-label-lead-meta {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.inbox-label-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Rodapé minimalista */
.icv-mini {
  border-radius: 7px;
}

.icv-mini-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  padding: 0.15rem 0;
  width: fit-content;
}

.icv-mini-summary::-webkit-details-marker {
  display: none;
}

.icv-mini-summary::before {
  content: '＋';
  font-size: 0.85rem;
  line-height: 1;
}

.icv-mini[open] .icv-mini-summary::before {
  content: '－';
}

.icv-mini[open] .icv-mini-summary {
  color: var(--text);
}

.icv-mini-input {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.76rem;
}

.icv-mini-input:focus {
  outline: none;
  border-color: var(--green);
}

/* Modelo pronto — compacto, por último */
.icv-template-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding-top: 0.1rem;
}

.icv-template-label {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.icv-template {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
}

.icv-template:focus {
  outline: none;
  border-color: var(--green);
}

.icv-compose-main {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.icv-textarea {
  flex: 1;
  resize: none;
  min-height: 56px;
  max-height: 170px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
}

.icv-textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(0, 133, 113, 0.18);
}

.icv-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.icv-send:hover {
  background: #00a48c;
}

.icv-send:active {
  transform: scale(0.94);
}

.inbox-reply-card[open] .inbox-reply-body {
  max-height: none;
  overflow: visible;
}

.inbox-bot-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.inbox-bot-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.inbox-bot-switch-ui {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.inbox-bot-switch-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}

.inbox-bot-switch input:checked + .inbox-bot-switch-ui {
  background: rgba(0, 133, 113, 0.25);
  border-color: var(--green);
}

.inbox-bot-switch input:checked + .inbox-bot-switch-ui::after {
  transform: translateX(16px);
  background: var(--green);
}

.inbox-bot-switch-text strong {
  font-size: 0.78rem;
}

.inbox-bot-switch-text small {
  font-size: 0.66rem;
  color: var(--muted);
}

.inbox-kind-tabs {
  display: flex;
  padding: 2px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  gap: 2px;
  margin-bottom: 0.35rem;
}

.inbox-kind-tab {
  flex: 1;
  padding: 0.3rem 0.25rem;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.inbox-kind-tab:hover {
  color: var(--text);
}

.inbox-kind-tab.active {
  background: var(--surface2);
  color: var(--text);
}

.inbox-bot-switch-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.inbox-kind-hint {
  margin: 0 0 0.4rem;
  font-size: 0.66rem;
  color: var(--muted);
  line-height: 1.35;
}

.inbox-manual-top {
  margin-bottom: 0.4rem;
}

.inbox-control-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.45rem;
}

.inbox-control-field-tight {
  margin-bottom: 0.4rem;
}

.inbox-control-label {
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--muted);
}

.inbox-control-label .label-optional {
  font-weight: 400;
  opacity: 0.75;
}

.inbox-control-input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
}

.inbox-control-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(0, 133, 113, 0.18);
}

.inbox-control-textarea {
  min-height: 64px;
  max-height: 96px;
  resize: vertical;
  line-height: 1.4;
}

.inbox-control-subblock {
  margin-bottom: 0.45rem;
  padding: 0.45rem 0.5rem;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
}

.inbox-btn-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.inbox-cta-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0.35rem;
  align-items: start;
}

.inbox-cta-row .inbox-control-field-tight {
  margin-bottom: 0;
}

.inbox-control-section .btn-block {
  margin-top: 0.25rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
}

.inbox-field-compact {
  margin-bottom: 0.4rem;
}

.inbox-reply-card {
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}

.inbox-reply-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 600;
  list-style: none;
  user-select: none;
}

.inbox-reply-summary::-webkit-details-marker {
  display: none;
}

.inbox-reply-summary::before {
  content: '▸';
  margin-right: 0.35rem;
  color: var(--muted);
  transition: transform 0.15s;
}

.inbox-reply-card[open] .inbox-reply-summary::before {
  transform: rotate(90deg);
}

.inbox-reply-badge {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--surface2);
}

.inbox-reply-body {
  padding: 0 0.55rem 0.55rem;
  border-top: 1px solid var(--border);
}

.inbox-reply-pick {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.45rem;
}

.inbox-reply-card--selected .inbox-reply-summary {
  color: var(--green);
}

.inbox-pick-btn {
  display: block;
  width: 100%;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.inbox-pick-btn:hover {
  border-color: var(--muted);
  background: var(--surface2);
}

.inbox-pick-btn.active {
  border-color: var(--green);
  background: rgba(0, 133, 113, 0.1);
}

.inbox-pick-title {
  font-size: 0.74rem;
  font-weight: 600;
}

.inbox-config-section[hidden],
.inbox-action-panel[hidden] {
  display: none !important;
}

.inbox-action-panel {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin-bottom: 0.4rem;
}

/* Botões de ação lado a lado, dividindo o espaço */
#inbox-action-config {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.4rem;
}

#inbox-action-config .inbox-action-item {
  flex: 1 1 0;
  min-width: 0;
}

#inbox-action-config .inbox-action-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.12rem;
}

#inbox-action-config .inbox-add-btn {
  width: 2.1rem;
  align-self: stretch;
  flex-shrink: 0;
}

.inbox-action-item[hidden] {
  display: none !important;
}

.inbox-action-item {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  padding: 0.32rem 0.38rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.inbox-action-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 1rem;
}

.inbox-action-num {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
}

.inbox-action-remove {
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.inbox-action-remove:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.inbox-action-field {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  align-items: center;
  gap: 0.28rem;
  margin: 0;
}

.inbox-action-field > span {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--muted);
}

.inbox-action-field.inbox-action-extra[hidden] {
  display: none !important;
}

.inbox-action-input {
  width: 100%;
  min-width: 0;
  padding: 0.26rem 0.38rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.68rem;
  line-height: 1.25;
}

.inbox-action-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(0, 133, 113, 0.2);
}

.inbox-action-textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.45;
}

.inbox-action-hint {
  margin: 0.25rem 0 0;
  font-size: 11px;
  color: var(--gray-500);
  line-height: 1.4;
}

.inbox-action-extra {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px dashed var(--gray-200);
}

.inbox-action-extra[hidden] {
  display: none !important;
}

.inbox-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.22rem;
  border: 1px dashed var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.inbox-add-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(0, 133, 113, 0.08);
}

.inbox-add-btn[hidden] {
  display: none !important;
}

@media (max-width: 960px) {
  .inbox-detail-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .inbox-phone-panel {
    max-width: none;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .inbox-phone-wrap {
    justify-content: center;
  }

  .inbox-wa-preview .iphone-shell-inner {
    height: 340px;
  }

  .inbox-btn-row,
  .inbox-cta-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .inbox-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 200px 1fr;
  }
}

/* ── Leads ── */
.leads-wrap { display: flex; flex-direction: column; gap: 16px; }

.leads-counts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.leads-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.leads-count .lc-num { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.leads-count .lc-label { font-size: 12px; color: var(--muted); }
.leads-count.awaiting { border-left: 3px solid var(--muted); }
.leads-count.pending { border-left: 3px solid var(--amber); }
.leads-count.paid { border-left: 3px solid var(--green); }

.leads-filters { display: flex; flex-direction: column; gap: 10px; }
.leads-date-filters, .leads-status-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lead-date-btn, .lead-status-btn, .lead-refresh {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
}
.lead-date-btn:hover, .lead-status-btn:hover, .lead-refresh:hover { color: var(--text); border-color: var(--muted); }
.lead-date-btn.active, .lead-status-btn.active {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--text);
}
.lead-refresh { margin-left: auto; font-size: 16px; line-height: 1; padding: 6px 12px; }

.leads-custom-date { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.leads-custom-date input[type="date"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
}

.leads-list { display: flex; flex-direction: column; gap: 8px; }
.leads-empty { color: var(--muted); text-align: center; padding: 40px 0; font-size: 14px; }
.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.lead-card:hover { border-color: var(--muted); }
.lead-main { min-width: 0; }
.lead-name { font-weight: 600; color: var(--text); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-phone { font-size: 13px; color: var(--muted); }
.lead-meta { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.lead-dates { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); text-align: right; }
.lead-status {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.lead-status.awaiting { background: rgba(139,156,179,.15); color: var(--muted); }
.lead-status.pending { background: rgba(230,162,60,.15); color: var(--amber); }
.lead-status.paid { background: rgba(0,133,113,.18); color: #2fd6b8; }

@media (max-width: 720px) {
  .leads-counts { grid-template-columns: repeat(2, 1fr); }
  .lead-card { flex-direction: column; align-items: flex-start; }
  .lead-meta { width: 100%; justify-content: space-between; }
  .lead-dates { text-align: left; }
}

/* ── Remarketing ── */
.rmkt-layout { display: flex; gap: 18px; align-items: flex-start; }
.rmkt-layout > .rmkt-wrap { flex: 1 1 auto; min-width: 0; }

.rmkt-side {
  flex: 0 0 360px;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 90px);
  display: flex;
  flex-direction: column;
}
.rmkt-side-head h3 { margin: 0; font-size: 15px; color: var(--text); }
.rmkt-side-sub { margin: 4px 0 12px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }

.rmkt-side-tabs { display: flex; gap: 6px; margin-bottom: 12px; background: var(--bg, rgba(0,0,0,0.04)); padding: 3px; border-radius: 9px; }
.rmkt-side-tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 7px 8px; border-radius: 7px; transition: background 0.15s, color 0.15s;
}
.rmkt-side-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.rmkt-side-tab .cnt { opacity: 0.7; font-weight: 700; }

.rmkt-proximos { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding-right: 2px; }
.rmkt-prox-empty { font-size: 12.5px; color: var(--muted); padding: 18px 4px; text-align: center; }

.rmkt-done {
  border: 1px solid var(--border);
  border-left: 3px solid #94a3b8;
  border-radius: 9px;
  padding: 9px 10px;
  background: var(--bg, #fff);
}
.rmkt-done.ok { border-left-color: #22c55e; background: rgba(34, 197, 94, 0.06); }
.rmkt-done-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.rmkt-done-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmkt-done-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.rmkt-done-when { font-size: 11px; color: var(--muted); white-space: nowrap; }
.rmkt-done-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.rmkt-done-badge.ok { background: rgba(34, 197, 94, 0.15); color: #15803d; }
.rmkt-done-badge.fim { background: rgba(148, 163, 184, 0.2); color: #475569; }

.rmkt-prox {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  background: var(--bg, #fff);
}
.rmkt-prox.urgente { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.06); }
.rmkt-prox-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.rmkt-prox-when { font-size: 11.5px; font-weight: 700; color: var(--text); white-space: nowrap; }
.rmkt-prox.urgente .rmkt-prox-when { color: #b45309; }
.rmkt-prox-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmkt-prox-step { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.rmkt-prox-preview { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.rmkt-seg-badge { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.rmkt-seg-badge.a { background: rgba(59, 130, 246, 0.14); color: #1d4ed8; }
.rmkt-seg-badge.b { background: rgba(168, 85, 247, 0.14); color: #7c3aed; }

.rmkt-ed-toggle { flex-direction: row !important; align-items: center; gap: 6px !important; font-size: 12px; }
.rmkt-ed-toggle input { width: auto !important; }

@media (max-width: 1100px) {
  .rmkt-layout { flex-direction: column; }
  .rmkt-side { width: 100%; flex-basis: auto; position: static; max-height: none; }
  .rmkt-proximos { max-height: 420px; }
}

.rmkt-wrap { display: flex; flex-direction: column; gap: 16px; }

.rmkt-toggle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.rmkt-toggle-title { font-weight: 700; color: var(--text); font-size: 16px; }
.rmkt-toggle-sub { font-size: 13px; color: var(--muted); margin-top: 2px; max-width: 560px; }

.rmkt-switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.rmkt-switch input { opacity: 0; width: 0; height: 0; }
.rmkt-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 999px; transition: .2s;
}
.rmkt-slider::before {
  content: ''; position: absolute; height: 22px; width: 22px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.rmkt-switch input:checked + .rmkt-slider { background: var(--green); }
.rmkt-switch input:checked + .rmkt-slider::before { transform: translateX(22px); }

.rmkt-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.rmkt-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.rmkt-count .rc-num { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.rmkt-count .rc-label { font-size: 12px; color: var(--muted); }
.rmkt-count.paid { border-left: 3px solid var(--green); }

.rmkt-segments { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.rmkt-seg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.rmkt-seg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.rmkt-seg-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.rmkt-seg-badge.a { background: rgba(230,162,60,.15); color: var(--amber); }
.rmkt-seg-badge.b { background: rgba(0,133,113,.18); color: #2fd6b8; }
.rmkt-seg-title { font-size: 14px; color: var(--text); font-weight: 600; }
.rmkt-seg-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.rmkt-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.rmkt-steps li { font-size: 13px; color: var(--text); }
.rmkt-step-when {
  display: inline-block; font-size: 11px; color: var(--muted);
  background: var(--bg, rgba(255,255,255,.04)); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px; margin-right: 6px;
}
.rmkt-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0; }

/* Abas Fluxograma / Editor */
.rmkt-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); }
.rmkt-tab {
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.rmkt-tab:hover { color: var(--text); }
.rmkt-tab.active { color: var(--green); border-bottom-color: var(--green); }
.rmkt-pane[hidden] { display: none; }
.rmkt-flow-empty { font-size: 13px; color: var(--muted); }

/* Fluxograma */
.rmkt-flow { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.flow-col { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
.flow-start, .flow-end {
  text-align: center; font-size: 12px; font-weight: 700;
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
}
.flow-start-a { background: rgba(230,162,60,.15); color: var(--amber); border-color: rgba(230,162,60,.3); }
.flow-start-b { background: rgba(0,133,113,.18); color: #2fd6b8; border-color: rgba(0,133,113,.35); }
.flow-end { background: rgba(0,133,113,.1); color: #2fd6b8; }
.flow-down { text-align: center; color: var(--muted); font-size: 11px; line-height: 1.4; padding: 2px 0; }
.flow-node {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}
.flow-node-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.flow-step-id { font-size: 12px; font-weight: 700; color: var(--text); }
.flow-when { font-size: 11px; color: var(--muted); background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; }
.flow-msg { font-size: 12px; color: var(--text); line-height: 1.45; margin-bottom: 10px; white-space: normal; }
.flow-branches { display: flex; flex-direction: column; gap: 6px; }
.flow-branch { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.flow-arrow { color: var(--muted); }
.flow-btn-pill { background: var(--green); color: #fff; border-radius: 6px; padding: 2px 8px; font-weight: 600; }
.flow-act { border-radius: 6px; padding: 2px 8px; font-weight: 600; }
.flow-act.tag-pausa { background: rgba(230,162,60,.15); color: var(--amber); }
.flow-act.tag-segue { background: rgba(80,140,255,.15); color: #7aa7ff; }
.flow-act.tag-fim { background: rgba(255,90,90,.14); color: #ff8c8c; }
.flow-dest { color: var(--muted); }

/* Editor da cadência */
.rmkt-editor { display: flex; flex-direction: column; gap: 16px; }
.rmkt-ed-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.rmkt-ed-block h4 { margin: 0 0 4px; font-size: 14px; color: var(--text); }
.rmkt-ed-hint { font-size: 12px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.rmkt-ed-hint code { background: rgba(255,255,255,.06); border-radius: 4px; padding: 1px 5px; font-size: 11px; }
.rmkt-ed-row { display: flex; gap: 12px; flex-wrap: wrap; }
.rmkt-ed-block label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.rmkt-ed-block input, .rmkt-ed-block textarea, .rmkt-ed-block select {
  background: var(--bg, rgba(0,0,0,.15)); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 13px; font-family: inherit;
}
.rmkt-ed-block textarea { width: 100%; resize: vertical; }
.rmkt-ed-step {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  margin-top: 10px; display: flex; flex-direction: column; gap: 8px;
}
.rmkt-ed-step-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rmkt-ed-id { font-size: 12px; font-weight: 700; color: var(--text); }
.rmkt-ed-tipo { font-size: 11px; color: var(--muted); margin-left: auto; }
.rmkt-ed-when { font-size: 11px; color: var(--muted); flex-direction: row !important; align-items: center; gap: 6px !important; }
.rmkt-ed-when input { width: 80px; }
.rmkt-ed-btns-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.rmkt-ed-btn { display: flex; gap: 8px; }
.rmkt-ed-btn input { flex: 1; }
.rmkt-ed-btn select { flex: 1; }
.rmkt-save-status { font-size: 12px; color: var(--muted); align-self: center; }
.rmkt-save-status.ok { color: var(--green); }
.rmkt-save-status.err { color: #ff8c8c; }

@media (max-width: 720px) {
  .rmkt-counts { grid-template-columns: repeat(2, 1fr); }
  .rmkt-segments { grid-template-columns: 1fr; }
  .rmkt-flow { grid-template-columns: 1fr; }
}

/* ── Consulta ── */
.consulta-wrap { display: flex; flex-direction: column; gap: 14px; }
.consulta-tipos { display: flex; flex-wrap: wrap; gap: 8px; }
.consulta-tipo-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
}
.consulta-tipo-btn:hover { color: var(--text); border-color: var(--muted); }
.consulta-tipo-btn.active { background: var(--green-dim); border-color: var(--green); color: var(--text); }

.consulta-search { display: flex; gap: 8px; }
.consulta-search input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
}
.consulta-btn {
  background: var(--green);
  border: none;
  color: #fff;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.consulta-btn:hover { background: var(--green-dark); }

.consulta-results { display: flex; flex-direction: column; gap: 12px; }
.consulta-empty { color: var(--muted); text-align: center; padding: 36px 0; font-size: 14px; }
.consulta-count { font-size: 13px; color: var(--muted); }

.consulta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.consulta-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.consulta-name { font-weight: 700; color: var(--text); font-size: 16px; }
.consulta-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.consulta-head-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.consulta-badge { font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.consulta-badge.awaiting { background: rgba(139,156,179,.15); color: var(--muted); }
.consulta-badge.pending { background: rgba(230,162,60,.15); color: var(--amber); }
.consulta-badge.paid { background: rgba(0,133,113,.18); color: #2fd6b8; }
.consulta-open {
  background: var(--green-dim);
  border: 1px solid var(--green);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
.consulta-open:hover { background: var(--green); color: #fff; }

.consulta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; }
.consulta-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.consulta-row .cr-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.consulta-row .cr-val { font-size: 14px; color: var(--text); word-break: break-word; }

@media (max-width: 720px) {
  .consulta-grid { grid-template-columns: 1fr; }
  .consulta-card-head { flex-direction: column; }
}

.views.views-labels-active {
  max-width: none !important;
  width: 100% !important;
  padding: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#view-labels.labels-page.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* ── Etiquetas (layout full-width) ── */
.labels-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--border);
}

.labels-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.labels-panel--config {
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.labels-panel--calibrator {
  background: #0c1018;
}

.labels-panel--preview {
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.labels-panel-head {
  flex-shrink: 0;
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

.labels-panel-head h2 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}

.labels-panel-head .sub {
  margin: 0;
  font-size: 0.78rem;
}

.labels-panel-head--row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.labels-panel-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

.labels-panel-foot {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.labels-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.labels-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.labels-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.labels-calibrator-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.labels-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex-shrink: 0;
}

.labels-lead-bar {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.labels-lead-field {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.labels-lead-field span {
  font-size: 0.72rem;
}

.labels-preview-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #0a0e14;
}

.labels-preview-empty {
  margin: auto;
  max-width: 280px;
  font-size: 0.84rem;
  line-height: 1.55;
  text-align: center;
  padding: 2rem 1.25rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
}

.labels-preview-empty[hidden] {
  display: none;
}

@media (max-width: 1100px) {
  .labels-shell {
    grid-template-columns: 250px minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .labels-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-y: auto;
  }

  .labels-panel {
    overflow: visible;
    max-height: none;
  }

  .labels-panel--config {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .labels-panel--preview {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .labels-calibrator-stage,
  .labels-preview-stage {
    min-height: 320px;
  }
}

.label-upload-btn {
  display: inline-flex;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.labels-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.label-field-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.label-field-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  font-size: 0.75rem;
  cursor: pointer;
}

.label-field-item.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
}

.label-field-type {
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
}

.label-static-values .label-static-field textarea {
  min-height: 3.2rem;
  resize: vertical;
}

.label-static-values .field span {
  font-size: 0.72rem;
}

.label-field-item .label-field-type:empty {
  display: none;
}

.label-field-item[data-static="1"] .label-field-type,
.label-field-item:has(.label-field-type:where(:not(:empty))) .label-field-type {
  color: var(--muted);
}

.label-field-name + .label-field-type {
  margin-left: auto;
}

.label-field-item .label-field-type {
  color: #818cf8;
}

.label-field-editor .field {
  margin-bottom: 0.5rem;
}

.label-field-editor h3 {
  font-size: 0.85rem;
  margin: 0 0 0.65rem;
}

.label-save-status {
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0.75rem 0;
}

.label-save-status code {
  font-size: 0.72rem;
}

.label-backup-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.label-backup-field {
  flex: 1;
  min-width: 0;
}

.label-calibrator-wrap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.label-template-img {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.label-calibrator-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.label-box {
  position: absolute;
  border: 1px dashed rgba(99, 102, 241, 0.9);
  background: rgba(99, 102, 241, 0.18);
  pointer-events: auto;
  cursor: move;
  box-sizing: border-box;
  overflow: visible;
  padding: 1px 3px 3px;
  min-height: 10px;
}

.label-box.active {
  border-color: #22c55e;
  border-width: 2px;
  background: rgba(34, 197, 94, 0.22);
  z-index: 3;
}

.label-box-label {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 9px;
  font-weight: 700;
  color: #6366f1;
  line-height: 1.15;
  white-space: normal;
  word-break: break-word;
  pointer-events: none;
  text-shadow: 0 0 2px #fff, 0 0 4px #fff;
}

.label-box.active .label-box-label {
  color: #15803d;
}

.label-box[data-align="right"] .label-box-label {
  text-align: right;
}

.label-box[data-align="center"] .label-box-label {
  text-align: center;
}

.label-box-resize {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  cursor: nwse-resize;
  background: rgba(99, 102, 241, 0.95);
  border: 1px solid #fff;
  border-radius: 2px 0 0 0;
  pointer-events: auto;
  z-index: 4;
}

.label-box.active .label-box-resize {
  background: #22c55e;
}

.label-preview-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.label-preview-img[hidden] {
  display: none;
}
