:root {
  /* Paleta Oficial: Nicolas Matheus — Zé Gotinha */
  --bg-app: #18191a;
  --bg-sidebar: #1e2024;
  --bg-card: #242628;
  --bg-elevated: #2b2e33;
  --bg-hover: #33373e;
  --border: #333842;
  --text-main: #f7f5f1;
  --text-muted: #9ea7b4;
  --gold: #bc9657;
  --gold-light: #ceaf78;
  --gold-text: #f0d5a3;
  --accent: #bc9657;
  --accent-hover: #ceaf78;
  --niche-color: #bc9657;
  --whatsapp: #00a884;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #0ea5e9;
  --msg-in: #24272d;
  --msg-out: #0b4f41;
  --msg-note: #3d3317;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 14px;
  overflow: hidden;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #2f3f49;
  border-radius: 99px;
}

.hidden { display: none !important; }

/* LAYOUT */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  width: 100vw;
}

/* SIDEBAR */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(188, 150, 87, 0.08), transparent);
}
.brand-logo-img {
  width: 100%;
  max-height: 54px;
  object-fit: contain;
  object-position: left center;
  display: block;
}
.brand-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.brand-app-tag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold-text);
  background: rgba(188, 150, 87, 0.14);
  border: 1px solid rgba(188, 150, 87, 0.35);
  padding: 2px 7px;
  border-radius: 6px;
}
.author-signature {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.25;
}
.author-signature strong {
  color: var(--gold-text);
}
.sig-gota {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}
.ws-status {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.ws-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  display: inline-block;
}
.ws-status.online .dot {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e88;
}

.niche-section {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  padding: 0 4px;
}
.icon-btn-sm {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-main);
  cursor: pointer;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.icon-btn-sm:hover { background: var(--accent); border-color: var(--accent); color: #052e16; }

.niche-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 185px;
  overflow-y: auto;
}
.niche-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.niche-pill:hover { background: var(--bg-elevated); }
.niche-pill.active {
  background: var(--bg-elevated);
  border-color: var(--niche-color);
  box-shadow: inset 3px 0 0 var(--niche-color);
}
.niche-pill-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.niche-pill-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  font-size: 13px;
}
.niche-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 99px;
  background: #22303a;
  color: var(--text-muted);
}
.niche-count.unread {
  background: var(--accent);
  color: #042f2e;
  font-weight: 700;
}

.nav-menu {
  flex: 1;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  text-align: left;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text-main); }
.nav-item.active {
  background: color-mix(in srgb, var(--niche-color) 18%, transparent);
  color: var(--text-main);
  font-weight: 600;
}
.nav-ico { font-size: 16px; width: 20px; text-align: center; }
.badge-pill {
  margin-left: auto;
  background: var(--accent);
  color: #042f2e;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 99px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* MAIN AREA */
.main-area {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.topbar {
  height: 60px;
  padding: 0 22px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-left h1 {
  font-size: 17px;
  font-weight: 700;
}
.active-niche-badge {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: color-mix(in srgb, var(--niche-color) 20%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--niche-color) 55%, transparent);
  color: var(--text-main);
}
.topbar-actions {
  display: flex;
  gap: 10px;
}

.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}
.view-container.no-pad {
  padding: 0;
  overflow: hidden;
}

/* BUTTONS & INPUTS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-primary { background: var(--gold); color: #18191a; }
.btn-primary:hover { background: var(--gold-light); }
.btn-accent { background: var(--niche-color); color: #fff; }
.btn-accent:hover { filter: brightness(1.1); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-elevated); }
.btn-danger { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.btn-danger:hover { background: #ef4444; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-app);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
}
.textarea { resize: vertical; min-height: 76px; }
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* CARDS & GRIDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-sub { font-size: 11.5px; color: var(--text-muted); }

.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.funnel-bar-row {
  margin-bottom: 12px;
}
.funnel-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
}
.funnel-bar-track {
  height: 10px;
  background: var(--bg-app);
  border-radius: 99px;
  overflow: hidden;
}
.funnel-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
}

.activity-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--niche-color);
  margin-top: 5px;
  flex-shrink: 0;
}

/* CHAT WORKSPACE (3 COLUMNS) */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr 330px;
  height: 100%;
}
.chat-list-pane {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-list-controls {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-filter-tabs {
  display: flex;
  gap: 4px;
}
.chip-tab {
  flex: 1;
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.chip-tab.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--accent);
}
.chat-contacts {
  flex: 1;
  overflow-y: auto;
}
.chat-contact-item {
  display: flex;
  gap: 11px;
  padding: 12px;
  border-bottom: 1px solid rgba(38, 53, 63, 0.5);
  cursor: pointer;
  transition: background 0.12s;
}
.chat-contact-item:hover { background: var(--bg-card); }
.chat-contact-item.active { background: var(--bg-elevated); }
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  font-size: 15px;
}
.chat-contact-meta {
  flex: 1;
  min-width: 0;
}
.chat-contact-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.chat-contact-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.chat-preview {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  color: #fff;
  margin-right: 4px;
  margin-bottom: 3px;
}

/* CHAT THREAD */
.chat-thread-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  background-image: radial-gradient(rgba(188, 150, 87, 0.06) 1px, transparent 0);
  background-size: 22px 22px;
  overflow: hidden;
}
.chat-header {
  height: 62px;
  padding: 0 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg-bubble {
  max-width: 74%;
  padding: 9px 13px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.msg-bubble.in {
  align-self: flex-start;
  background: var(--msg-in);
  border-top-left-radius: 3px;
}
.msg-bubble.out {
  align-self: flex-end;
  background: var(--msg-out);
  border-top-right-radius: 3px;
}
.msg-bubble.note {
  align-self: center;
  max-width: 85%;
  background: var(--msg-note);
  border: 1px dashed #eab308;
  color: #fef08a;
}
.msg-sender {
  font-size: 11px;
  font-weight: 700;
  color: #5eead4;
  margin-bottom: 3px;
}
.msg-time {
  font-size: 10.5px;
  color: rgba(233, 237, 239, 0.65);
  text-align: right;
  margin-top: 4px;
}

.chat-composer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.composer-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.quick-reply-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.qr-pill {
  padding: 3px 9px;
  font-size: 11.5px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
}
.qr-pill:hover { border-color: var(--accent); color: var(--accent-hover); }

/* CRM INSPECTOR */
.chat-inspector {
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}
.inspector-section {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.inspector-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.tag-toggle-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-toggle {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-muted);
}
.tag-toggle.selected {
  color: #fff;
  border-color: transparent;
}

/* KANBAN */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  height: calc(100vh - 110px);
  padding-bottom: 12px;
}
.kanban-col {
  min-width: 290px;
  max-width: 290px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 100%;
}
.kanban-col.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-sidebar));
}
.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--niche-color);
  border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-col-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13.5px;
}
.kanban-col-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}
.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: transform 0.12s, border-color 0.12s;
}
.kanban-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.kanban-card-title {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kanban-card-phone { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kanban-card-val { font-size: 13px; font-weight: 700; color: #34d399; margin-bottom: 6px; }
.kanban-card-custom {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-app);
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
}

/* TABLES */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th {
  background: var(--bg-sidebar);
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tr:hover td { background: rgba(255,255,255,0.02); }

/* RAFFLE STAGE */
.raffle-box {
  background: linear-gradient(135deg, rgba(139,92,246,0.18), rgba(16,185,129,0.14));
  border: 1px solid color-mix(in srgb, var(--niche-color) 60%, var(--border));
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.raffle-display {
  font-size: 28px;
  font-weight: 800;
  margin: 16px 0;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--bg-app);
  border: 1px dashed var(--accent);
  min-height: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* QR & WHATSAPP CARDS */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
}
.status-pill.connected { background: rgba(16,185,129,0.18); color: #34d399; }
.status-pill.qr_pending { background: rgba(245,158,11,0.18); color: #fbbf24; }
.status-pill.disconnected { background: rgba(239,68,68,0.18); color: #f87171; }

.qr-preview {
  margin-top: 12px;
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  display: inline-block;
}
.qr-preview img { width: 210px; height: 210px; display: block; }

.code-box {
  background: var(--bg-app);
  border: 1px solid var(--border);
  padding: 9px 12px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #7dd3fc;
  word-break: break-all;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.68);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 4000;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:hover { color: var(--text-main); }
.modal-body {
  padding: 18px;
  overflow-y: auto;
}

/* TOASTS */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5000;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  color: var(--text-main);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  animation: slideIn 0.2s ease;
}
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-muted);
}
.empty-state .big-ico { font-size: 40px; margin-bottom: 10px; }

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.subtab {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}
.subtab.active {
  background: var(--niche-color);
  border-color: var(--niche-color);
  color: #fff;
}

.progress-bar {
  height: 8px;
  background: var(--bg-app);
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s;
}

.badge-warn {
  background: #f59e0b !important;
  color: #18191a !important;
}
.badge-danger {
  background: #ef4444 !important;
  color: #fff !important;
}

/* BEGINNER BANNER & GUIDE */
.beginner-banner {
  background: linear-gradient(135deg, rgba(188, 150, 87, 0.16), rgba(36, 38, 40, 0.95));
  border: 1px solid rgba(188, 150, 87, 0.45);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.guide-step-card {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.guide-step-card h4 {
  color: var(--gold-text);
  margin-bottom: 4px;
  font-size: 13.5px;
}
.guide-step-card p {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* SLA & TEMPERATURE & OUTCOME PILLS */
.sla-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
}
.sla-ok { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.sla-warn { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.sla-late { background: rgba(239, 68, 68, 0.2); color: #f87171; }

.outcome-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.outcome-btn {
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.outcome-btn.active-open { border-color: var(--info); color: #38bdf8; background: rgba(14,165,233,0.14); }
.outcome-btn.active-won { border-color: #22c55e; color: #4ade80; background: rgba(34,197,94,0.16); }
.outcome-btn.active-lost { border-color: #ef4444; color: #f87171; background: rgba(239,68,68,0.16); }

/* TASK ROWS */
.task-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  margin-bottom: 10px;
}
.task-row.overdue {
  border-left: 4px solid #ef4444;
}
.task-row.today {
  border-left: 4px solid #f59e0b;
}
.task-row.done {
  opacity: 0.55;
  border-left: 4px solid #22c55e;
}

/* TEMPLATE STORE CARDS */
.tpl-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
}
.tpl-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}
.tpl-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.tpl-stage-chip {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

@media print {
  .sidebar, .topbar-actions, .beginner-banner, .btn { display: none !important; }
  .app-shell { display: block !important; }
  body { background: #fff; color: #111; overflow: visible; }
  .card, .kpi-card { border: 1px solid #ccc; background: #fff; color: #111; break-inside: avoid; }
}

/* LOGIN & COMMERCIAL SESSION */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: radial-gradient(circle at top, #27241c 0%, #18191a 60%);
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(188, 150, 87, 0.45);
  border-radius: 16px;
  padding: 28px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}
.login-logo {
  width: 100%;
  max-height: 64px;
  object-fit: contain;
  margin-bottom: 10px;
}
.login-subtitle {
  text-align: center;
  font-size: 12.5px;
  color: var(--gold-text);
  margin-bottom: 18px;
}
.login-error {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 12px;
}
.login-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
}
.user-session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.safe-callout {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.warn-callout {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}

/* MEDIA BUBBLES, VOICE RECORDER & CATALOG */
.msg-media-img {
  max-width: 260px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.msg-media-audio {
  width: 250px;
  height: 36px;
  margin-bottom: 4px;
  display: block;
}
.msg-media-doc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: var(--gold-text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
}
.msg-media-doc:hover {
  background: rgba(0, 0, 0, 0.4);
}
.recording-active {
  background: #dc2626 !important;
  color: #fff !important;
  animation: pulseRec 1s infinite;
}
@keyframes pulseRec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}
.catalog-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.catalog-img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
}
.catalog-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

/* CUSTOMIZABLE CLIENT THEMES & IMPERSONATION BAR */
body[data-theme="midnight"] {
  --bg-app: #0b1120;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #273549;
  --bg-hover: #334155;
  --border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --msg-in: #1e293b;
  --msg-out: #065f46;
}
body[data-theme="whatsapp_dark"] {
  --bg-app: #0b141a;
  --bg-sidebar: #111b21;
  --bg-card: #182229;
  --bg-elevated: #202c33;
  --bg-hover: #2a3942;
  --border: #26353f;
  --text-main: #e9edef;
  --text-muted: #8696a0;
  --msg-in: #202c33;
  --msg-out: #005c4b;
}
body[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-hover: #e2e8f0;
  --border: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --gold-text: var(--gold);
  --msg-in: #ffffff;
  --msg-out: #dcfce7;
  --msg-note: #fef9c3;
}
body[data-theme="light"] .msg-bubble.out,
body[data-theme="light"] .msg-bubble.in {
  color: #0f172a;
  border: 1px solid #cbd5e1;
}
body[data-theme="light"] .msg-bubble.note {
  color: #713f12;
  border-color: #eab308;
}
body[data-theme="light"] .msg-bubble.out .msg-time,
body[data-theme="light"] .msg-bubble.in .msg-time {
  color: #475569;
}
body[data-theme="light"] .msg-sender {
  color: #0284c7;
}
body[data-theme="light"] .niche-count {
  background: #e2e8f0;
  color: #334155;
}
body[data-theme="light"] .code-box {
  color: #0369a1;
  background: #f8fafc;
}
body[data-theme="light"] .msg-media-doc {
  background: rgba(15, 23, 42, 0.06);
  border-color: #cbd5e1;
  color: #0f172a;
}
body[data-theme="light"] .brand-logo-img {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.impersonation-banner {
  background: linear-gradient(90deg, #bc9657, #9a7432);
  color: #18191a;
  padding: 7px 22px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.color-swatch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 0.12s;
}
.color-swatch:hover {
  transform: scale(1.14);
}

/* ============================================================
   MOBILE & TABLET RESPONSIVE DESIGN (WHATSAPP MOBILE FEEL)
   ============================================================ */
.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  z-index: 2500;
}
.mobile-only-btn,
.mobile-bottom-nav,
.mobile-stage-tabs {
  display: none !important;
}

@media (max-width: 960px) {
  html, body {
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
  }
  .app-shell {
    display: flex !important;
    flex-direction: column !important;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
  }
  .main-area {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .mobile-only-btn {
    display: inline-flex !important;
  }
  .mobile-only-bar {
    display: flex !important;
  }
  .hide-mobile {
    display: none !important;
  }

  /* Native Bottom Tab Navigation Bar */
  .mobile-bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    height: 58px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 2000;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mob-nav-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
  }
  .mob-nav-btn .mob-ico {
    font-size: 18px;
    line-height: 1;
  }
  .mob-nav-btn.active {
    color: var(--gold);
    background: rgba(188, 150, 87, 0.08);
  }
  .mob-badge {
    position: absolute;
    top: 4px;
    right: 18%;
    background: var(--accent);
    color: #18191a;
    font-size: 10px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 99px;
  }

  /* Slide-over Drawer Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 285px;
    max-width: 85vw;
    height: 100dvh;
    z-index: 2600;
    transform: translateX(-105%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 12px 0 36px rgba(0, 0, 0, 0.75);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Compact Mobile Topbar */
  .topbar {
    height: 50px;
    padding: 0 10px;
    gap: 6px;
    flex-shrink: 0;
  }
  .topbar-left {
    gap: 8px;
    min-width: 0;
    flex: 1;
  }
  .topbar-left h1 {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .active-niche-badge {
    font-size: 11px;
    padding: 3px 7px;
    white-space: nowrap;
    max-width: 115px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions {
    gap: 4px;
    flex-shrink: 0;
  }
  .topbar-actions .btn {
    padding: 6px 8px;
    font-size: 13px;
  }

  .impersonation-banner {
    padding: 6px 10px;
    font-size: 11.5px;
    flex-wrap: wrap;
  }

  /* View Container & Cards */
  .view-container {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .view-container.no-pad {
    padding: 0;
    overflow: hidden;
  }
  .card {
    padding: 12px;
  }
  .beginner-banner {
    padding: 12px;
    gap: 10px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
  }
  .kpi-card {
    padding: 10px 12px;
  }
  .kpi-value {
    font-size: 19px;
  }
  .kpi-sub {
    font-size: 11px;
  }
  .dash-grid,
  .grid-2,
  .grid-3,
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  .subtabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
  .subtab {
    white-space: nowrap;
    padding: 7px 12px;
    font-size: 12px;
  }

  /* Mobile WhatsApp Chat (1 Full-Screen Pane at a time: List <-> Thread <-> CRM Ficha) */
  .chat-layout {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  .chat-layout[data-mobile-pane="list"] .chat-thread-pane,
  .chat-layout[data-mobile-pane="list"] .chat-inspector {
    display: none !important;
  }
  .chat-layout[data-mobile-pane="thread"] .chat-list-pane,
  .chat-layout[data-mobile-pane="thread"] .chat-inspector {
    display: none !important;
  }
  .chat-layout[data-mobile-pane="inspector"] .chat-list-pane,
  .chat-layout[data-mobile-pane="inspector"] .chat-thread-pane {
    display: none !important;
  }
  .chat-list-pane,
  .chat-thread-pane,
  .chat-inspector {
    width: 100%;
    height: 100%;
    flex: 1;
    border: none;
  }
  .chat-header {
    height: 52px;
    padding: 0 10px;
  }
  .chat-messages {
    padding: 10px;
  }
  .msg-bubble {
    max-width: 88%;
    font-size: 13.5px;
  }
  .msg-media-img {
    max-width: 200px;
  }
  .msg-media-audio {
    width: 200px;
  }
  .chat-composer {
    padding: 6px 8px;
    gap: 6px;
  }
  .composer-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .composer-toolbar .btn {
    flex-shrink: 0;
    padding: 4px 7px;
    font-size: 11px;
  }
  .quick-reply-bar {
    flex-wrap: nowrap;
  }
  .qr-pill {
    flex-shrink: 0;
  }

  /* Mobile Kanban: Instant Stage Selector Pill Bar + 1 Full-Width Column */
  .mobile-stage-tabs {
    display: flex !important;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 8px;
  }
  .mob-stage-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
  }
  .mob-stage-tab.active {
    background: var(--bg-elevated);
    color: var(--text-main);
    border-color: var(--st-color, var(--gold));
    box-shadow: inset 0 -2px 0 var(--st-color, var(--gold));
  }
  .kanban-board {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    padding-bottom: 20px;
  }
  .kanban-col.mob-hidden-col {
    display: none !important;
  }
  .kanban-col.mob-active-col {
    min-width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
  }

  /* Mobile Tables -> Clean Stacked Cards */
  .table-wrap {
    border: none;
    background: transparent;
  }
  table, thead, tbody, th, td, tr {
    display: block;
  }
  thead tr {
    display: none;
  }
  tbody tr {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  tbody td {
    border: none;
    padding: 4px 0;
    font-size: 13px;
  }

  /* Modals & Login on Mobile */
  .modal-overlay {
    padding: 8px;
  }
  .modal-card {
    max-height: 92dvh;
    border-radius: 12px;
  }
  .modal-header {
    padding: 11px 14px;
  }
  .modal-body {
    padding: 12px;
  }
  .login-overlay {
    padding: 12px;
  }
  .login-card {
    padding: 20px 16px;
  }
}

@media (max-width: 440px) {
  .active-niche-badge {
    display: none;
  }
}

/* ============================================================
   MÓDULO AGENDA PROFISSIONAL (SALÃO, CLÍNICA, SECRETÁRIA)
   ============================================================ */
.agenda-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.agenda-prof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}
.agenda-prof-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.agenda-prof-head {
  padding: 11px 14px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.agenda-prof-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.agenda-slot-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agenda-free-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.14s;
}
.agenda-free-slot:hover {
  border-color: var(--gold);
  color: var(--gold-text);
  background: rgba(188, 150, 87, 0.08);
}
.appt-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.appt-card.st-confirmado { border-left-color: #10b981; }
.appt-card.st-em_atendimento { border-left-color: #38bdf8; }
.appt-card.st-concluido { border-left-color: #22c55e; opacity: 0.78; }
.appt-card.st-faltou, .appt-card.st-cancelado { border-left-color: #ef4444; opacity: 0.62; }
.appt-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.appt-time { font-weight: 800; color: var(--gold-text); }
.appt-actions { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 2px; }
.agenda-week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: start;
}
.agenda-day-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agenda-day-col.is-today { border-color: var(--gold); }
.agenda-paywall {
  background: linear-gradient(135deg, rgba(188, 150, 87, 0.16), rgba(24, 25, 26, 0.96));
  border: 1px solid rgba(188, 150, 87, 0.5);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 780px;
  margin: 10px auto;
}
.agenda-paywall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.agenda-paywall-feat {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 12.5px;
}
