/* ============================================================
   Monado WP — Corporate Dark Theme
   ============================================================ */

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

:root {
  --primary: #1a56db;
  --primary-hover: #1e40af;
  --primary-light: rgba(26, 86, 219, 0.15);
  --accent: #0ea5e9;
  --accent-hover: #0284c7;
  --accent-light: rgba(14, 165, 233, 0.15);

  --success: #22c55e;
  --success-hover: #16a34a;
  --success-light: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --warning-hover: #d97706;
  --warning-light: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: rgba(239, 68, 68, 0.15);

  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #334155;
  --bg-hover: #283548;
  --surface: #1e293b;     /* card surface (== --bg2 no dark) */

  --text: #f1f5f9;
  --text2: #94a3b8;
  --text-muted: #64748b;

  --border: #475569;
  --border-light: #334155;

  /* Aliases pra compat (legado — codigo antigo usa estas) */
  --bg-secondary: #334155;
  --text-secondary: #94a3b8;
  --ack-read: #53bdeb;
  --warning-light: rgba(245,158,11,0.12);

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);

  --sidebar-width: 260px;
  --topbar-height: 0px;
  --transition: 0.2s ease;
}

html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  padding: 1rem;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 1.25rem;
  letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(26, 86, 219, 0.4);
}

.login-logo-img {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.25rem;
  display: block;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(26, 86, 219, 0.4);
}

.login-box h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text2);
  font-size: 0.85rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.login-box .form-group {
  text-align: left;
  margin-bottom: 1.25rem;
}

.login-box .btn {
  width: 100%;
  margin-top: 0.5rem;
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  display: none;
}

.login-error.show { display: block; }

/* ============================================================
   APP LAYOUT — Sidebar + Main
   ============================================================ */
.app {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg2);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  /* Em telas pequenas (laptops 13"/zoom alto), o conteudo pode estourar a viewport.
     Permitir scroll interno mantendo header/footer visiveis via min-height no nav. */
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Scrollbar discreta no menu lateral (so aparece quando necessario) */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }
.sidebar::-webkit-scrollbar-track { background: transparent; }

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

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-brand small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
}

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

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  color: var(--text2);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition);
  text-decoration: none;
}

.sidebar nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar nav a:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.sidebar nav a:hover svg { opacity: 1; }

.sidebar nav a.active {
  background: var(--primary-light);
  color: var(--accent);
}

.sidebar nav a.active svg { opacity: 1; }

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--radius);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logout:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Hamburger toggle */
.hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  color: var(--text);
}

.hamburger svg { width: 22px; height: 22px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* --- Main content --- */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.page-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Page sections (for SPA) --- */
.page { display: none; }
.page.active { display: block; animation: pageIn 0.2s ease; }

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

/* ============================================================
   CARDS GRID (Dashboard)
   ============================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--bg2);
  border: 1px solid rgba(71, 85, 105, 0.5);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.card-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.card-value.success { color: var(--success); }
.card-value.warning { color: var(--warning); }
.card-value.danger { color: var(--danger); }
.card-value.accent { color: var(--accent); }

.card-footer {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text2);
}

/* Chart container */
.chart-container {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.chart-container h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.chart-wrapper {
  position: relative;
  height: 280px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-container {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg3);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
}

tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--bg-hover); }

.table-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

/* Pagination */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text2);
}

.pagination {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.pagination button {
  background: var(--bg3);
  border: 1px solid var(--border-light);
  color: var(--text2);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--transition);
}

.pagination button:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination span {
  padding: 0 0.5rem;
  font-weight: 500;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-primary {
  background: var(--primary-light);
  color: var(--accent);
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text2);
}

.badge-tag {
  background: var(--bg3);
  color: var(--text2);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-right: 0.25rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: var(--success-hover); }

.btn-warning {
  background: var(--warning);
  color: #000;
}
.btn-warning:hover:not(:disabled) { background: var(--warning-hover); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--text2);
}

.btn-ghost {
  background: transparent;
  color: var(--text2);
  padding: 0.4rem 0.6rem;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--text);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn-sm svg { width: 14px; height: 14px; }

.btn-icon {
  padding: 0.4rem;
  min-width: unset;
}

/* Loading spinner inside button */
.btn .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.search-input {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-width: 220px;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-select {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.5rem 2rem 0.5rem 0.85rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  transition: border-color var(--transition);
}

.filter-select:focus { border-color: var(--primary); }

/* ============================================================
   FORM CONTROLS GLOBAIS (.form-input / .form-select / .form-textarea)
   Aplicado em drawer do flow, modais e qualquer formulario fora de .form-group
   ============================================================ */
.form-input,
.form-select,
.form-textarea,
textarea.form-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background-color: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
  outline: none;
  box-sizing: border-box;
}

.form-input::placeholder,
.form-textarea::placeholder,
textarea.form-input::placeholder {
  color: var(--text-muted);
}

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

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
textarea.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background-color: var(--bg2);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.form-textarea,
textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

/* Dropdown chevron customizado (substitui seta nativa cru) */
.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px 14px;
  padding-right: 2.25rem;
  cursor: pointer;
}

.form-select:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 12 12'%3E%3Cpath fill='%23f1f5f9' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px 14px;
}

/* Estiliza opcoes do dropdown nativo (suportado em Chrome/Edge/Firefox dark) */
.form-select option,
.form-group select option,
.filter-select option,
select option {
  background: var(--bg2);
  color: var(--text);
  padding: 8px;
}

.form-select optgroup,
.form-group select optgroup,
.filter-select optgroup,
select optgroup {
  background: var(--bg);
  color: var(--text2);
  font-weight: 600;
  font-style: normal;
  padding: 6px 0;
}

/* Aplica chevron tambem nos selects do .form-group para consistencia */
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px 14px;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* Schema de cor escuro para input/select (forca dropdown nativo dark) */
.form-input,
.form-select,
.form-textarea,
.form-group input,
.form-group select,
.form-group textarea,
.filter-select,
.search-input {
  color-scheme: dark;
}

/* ============================================================
   BASELINE GLOBAL — qualquer input/select/textarea sem classe
   herda contraste correto. Evita fonte preta em fundo escuro.
   ============================================================ */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]),
select,
textarea {
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border-light);
  color-scheme: dark;
  font-family: inherit;
}
select option, select optgroup {
  background-color: var(--bg2);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* Garante que selects herdem chevron + foco visual */
select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  padding: 1rem;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius);
  transition: all var(--transition);
  display: flex;
}

.modal-close:hover {
  background: var(--bg3);
  color: var(--text);
}

.modal-close:focus-visible {
  outline: 2px solid var(--accent);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.85rem 1.25rem;
  min-width: 280px;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn 0.3s ease forwards;
  border-left: 4px solid var(--border);
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--accent); }

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100px); }
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  opacity: 0.6;
  margin-left: auto;
}
.toast-close:hover { opacity: 1; }

/* ============================================================
   LOADING SKELETON
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg-hover) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.skeleton-cell {
  height: 14px;
  border-radius: 4px;
}

.skeleton-cell.w-sm { width: 60px; }
.skeleton-cell.w-md { width: 120px; }
.skeleton-cell.w-lg { width: 200px; }
.skeleton-cell.w-xl { width: 280px; }

.skeleton-card {
  height: 100px;
  border-radius: var(--radius-lg);
}

.skeleton-card-placeholder {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  animation: shimmer 1.5s infinite;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg-hover) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
}
.skeleton-card-placeholder .skeleton-line {
  height: 0.75rem;
  background: var(--bg3);
  border-radius: 4px;
  margin-bottom: 0.5rem;
}
.skeleton-card-placeholder .skeleton-line.wide { width: 60%; }
.skeleton-card-placeholder .skeleton-line.narrow { width: 30%; height: 1.5rem; }

.skeleton-chat-line {
  height: 2.5rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  animation: shimmer 1.5s infinite;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg-hover) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
}
.skeleton-chat-line:nth-child(odd) { width: 65%; }
.skeleton-chat-line:nth-child(even) { width: 45%; margin-left: auto; }

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg3);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.5s ease;
  background: var(--primary);
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }
.progress-fill.accent { background: var(--accent); }

.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text2);
  margin-top: 0.25rem;
  margin-bottom: 0.3rem;
}

.progress-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-inline .progress-bar {
  flex: 1;
  max-width: 100px;
}

.progress-inline span {
  font-size: 0.75rem;
  color: var(--text2);
  white-space: nowrap;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.85rem;
  max-width: 360px;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

/* ============================================================
   QR CODE MODAL
   ============================================================ */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

.qr-container img {
  max-width: 256px;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: #fff;
  padding: 0.5rem;
}

.qr-status {
  font-size: 0.85rem;
  color: var(--text2);
}

.qr-status.connected {
  color: var(--success);
  font-weight: 600;
}

/* ============================================================
   TEMPLATE PREVIEW
   ============================================================ */
.template-preview {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text2);
  white-space: pre-wrap;
  min-height: 50px;
}

.template-preview .highlight {
  color: var(--accent);
  font-weight: 600;
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-accent { color: var(--accent) !important; }
.text-muted { color: var(--text-muted) !important; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }

.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: 0.5rem; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============================================================
   RESPONSIVE — Mobile (< 768px)
   ============================================================ */
@media (max-width: 768px) {
  .hamburger { display: flex; }

  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-overlay.open {
    display: block;
  }

  .main {
    margin-left: 0;
    padding: 1rem;
    padding-top: 4rem;
  }

  .cards-grid {
    grid-template-columns: 1fr 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-actions {
    width: 100%;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input,
  .filter-select {
    width: 100%;
    min-width: unset;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 100%;
    margin: 0.5rem;
  }

  .toast {
    min-width: unset;
    max-width: calc(100vw - 2rem);
  }

  .chart-wrapper {
    height: 200px;
  }
}

@media (max-width: 480px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .login-box {
    padding: 1.75rem 1.25rem;
  }
}

/* ============================================================
   INBOX / CHAT
   ============================================================ */
.inbox-layout {
  display: flex;
  height: calc(100vh - 2rem);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg2);
}

.inbox-list {
  width: 340px;
  min-width: 280px;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
}

.inbox-list-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.inbox-list-header h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.inbox-list-header .search-input {
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
}

.inbox-conversations {
  flex: 1;
  overflow-y: auto;
}

.inbox-conv-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
}

.inbox-conv-item:hover { background: var(--bg-hover); }
.inbox-conv-item.active { background: var(--primary-light); }

.inbox-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text2);
  flex-shrink: 0;
}

.inbox-conv-info {
  flex: 1;
  min-width: 0;
}

.inbox-conv-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-conv-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.inbox-conv-meta {
  text-align: right;
  flex-shrink: 0;
}

.inbox-conv-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.inbox-conv-unread {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
  margin-top: 4px;
}

/* Chat area */
.inbox-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.inbox-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text2);
}

.inbox-chat-active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.inbox-chat-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.inbox-back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
}

.inbox-chat-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.inbox-chat-number {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.inbox-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inbox-msg {
  max-width: 70%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.inbox-msg-in {
  background: var(--bg3);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.inbox-msg-out {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.inbox-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.inbox-msg-out .inbox-msg-time {
  color: rgba(255,255,255,0.6);
}

.inbox-compose {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.inbox-compose textarea {
  flex: 1;
  resize: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
  min-height: 40px;
  max-height: 100px;
}

.inbox-compose .btn {
  padding: 0.6rem 0.75rem;
  display: flex;
  align-items: center;
}

/* Badge no menu */
.inbox-badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 4px;
}

/* Mobile inbox */
@media (max-width: 768px) {
  .inbox-layout { flex-direction: column; height: calc(100vh - 1rem); }
  .inbox-list { width: 100%; min-width: 100%; max-height: 100%; }
  .inbox-chat { display: none; }
  .inbox-layout.chat-open .inbox-list { display: none; }
  .inbox-layout.chat-open .inbox-chat { display: flex; }
  .inbox-back-btn { display: block; }
  .inbox-msg { max-width: 85%; }
}

/* ============================================================
   ASSIGN NUMBERS (checkbox list)
   ============================================================ */
.assign-numbers-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg3);
}

.assign-empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.assign-number-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

.assign-number-item:last-child { border-bottom: none; }
.assign-number-item:hover { background: var(--bg-hover); }

.assign-number-item input[type="checkbox"] {
  display: none;
}

.assign-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.assign-number-item input:checked + .assign-check {
  background: var(--primary);
  border-color: var(--primary);
}

.assign-number-item input:checked + .assign-check::after {
  content: '\2713';
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.assign-info {
  flex: 1;
  min-width: 0;
}

.assign-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.assign-number {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* ============================================================
   FILE UPLOAD STYLED
   ============================================================ */
.file-upload {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.file-upload input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg3);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}

.file-upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(26, 86, 219, 0.05);
}

.file-upload-name {
  font-size: 0.8rem;
  color: var(--text);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-preview {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--border-light);
}

/* ============================================================
   CUSTOM CONFIRM DIALOG
   ============================================================ */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.confirm-dialog {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 1rem;
  padding: 1.5rem; max-width: 400px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.confirm-dialog h4 { margin: 0 0 0.5rem; color: var(--text); font-size: 1.1rem; }
.confirm-dialog p { margin: 0 0 1.25rem; color: var(--text2); font-size: 0.9rem; line-height: 1.5; }
.confirm-dialog .confirm-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================================
   CONTEXTUAL ACTION MENU / DROPDOWN
   ============================================================ */
.action-menu { position: relative; display: inline-block; }
.action-menu-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 0.5rem;
  color: var(--text2); cursor: pointer; padding: 0.25rem 0.5rem; font-size: 1rem;
  transition: all 0.15s;
}
.action-menu-btn:hover { background: var(--bg3); color: var(--text); }
.action-menu-dropdown {
  display: none; position: fixed;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 0.75rem;
  min-width: 160px; z-index: 9999; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  padding: 0.25rem 0;
}
.action-menu-dropdown.show { display: block; animation: fadeIn 0.1s ease; }
.action-menu-dropdown button {
  display: block; width: 100%; text-align: left; padding: 0.5rem 1rem;
  background: none; border: none; color: var(--text2); font-size: 0.85rem;
  cursor: pointer; transition: background 0.1s;
}
.action-menu-dropdown button:hover { background: var(--bg3); color: var(--text); }
.action-menu-dropdown button.danger { color: var(--danger); }
.action-menu-dropdown button.danger:hover { background: rgba(239,68,68,0.1); }

/* Chip SIM inline inputs */
.chip-input {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 0.375rem;
  color: var(--text); padding: 0.3rem 0.5rem; width: 90px; font-size: 0.85rem;
  font-family: 'Consolas', monospace; text-align: center;
}
.chip-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,0.3); }

/* Sortable table headers */
th.sortable { cursor: pointer; user-select: none; position: relative; }
th.sortable:hover { color: var(--accent); }
th.sortable::after { content: '⇅'; margin-left: 4px; font-size: 0.7rem; color: var(--text-muted); }
th.sortable.sort-asc::after { content: '▲'; color: var(--accent); }
th.sortable.sort-desc::after { content: '▼'; color: var(--accent); }

/* ============================================================
   STAT CARDS (Health page)
   ============================================================ */
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  text-align: center;
}
.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================
   FINANCEIRO — Tabs & Panels
   ============================================================ */
.fin-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.2rem;
}

.fin-tab {
  background: transparent;
  color: var(--text2);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.fin-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.fin-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.fin-panel {
  animation: pageIn 0.2s ease;
}

/* Responsive charts grid */
@media (max-width: 960px) {
  #fin-summary > div[style*="grid-template-columns"],
  #page-financeiro [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   Help tooltips (?)  — hover to reveal definition of Meta jargon
   ============================================================ */
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--bg3, #2a2a2a);
  color: var(--text-muted, #999);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  border: 1px solid var(--border-light, #333);
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.help-tip:hover { background: var(--accent, #1f6feb); color: #fff; }

.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 280px;
  padding: 0.6rem 0.75rem;
  background: #111;
  color: #f5f5f5;
  border: 1px solid var(--border-light, #333);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s, visibility 0.18s;
  z-index: 9999;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}

.help-tip:hover::after,
.help-tip:focus::after {
  opacity: 1;
  visibility: visible;
}

/* Variante pra tooltips que cabem melhor abaixo (ex: cards no topo) */
.help-tip.below::after {
  bottom: auto;
  top: calc(100% + 8px);
}

/* ============================================================
   Janela de 24h — badge + banner no inbox
   ============================================================ */
.inbox-chat-window {
  margin-left: auto;
  padding-right: 0.75rem;
  display: flex;
  align-items: center;
}
.window-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}
.window-badge-open { background: rgba(34,197,94,0.15); color: #22c55e; border: 1px solid rgba(34,197,94,0.25); }
.window-badge-warning {
  background: rgba(245,158,11,0.18);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.3);
  animation: window-pulse 2s ease-in-out infinite;
}
.window-badge-closed { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid rgba(239,68,68,0.25); }
@keyframes window-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.window-banner {
  padding: 0.55rem 0.8rem;
  font-size: 12px;
  border-radius: 6px;
  margin: 0 0.75rem 0.5rem;
  line-height: 1.45;
}
.window-banner-warning { background: rgba(245,158,11,0.10); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
.window-banner-closed { background: rgba(239,68,68,0.10); color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.window-banner b, .window-banner strong { color: inherit; filter: brightness(1.15); }

/* ============================================================
   Admin · Contratos a Vencer
   ============================================================ */
.expiring-section .expiring-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.expiring-card {
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.expiring-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.18);
}
.expiring-card.active {
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(14,165,233,0.25);
}
.expiring-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.expiring-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}
.expiring-row:last-child { border-bottom: 0; }
.expiring-row:hover { background: rgba(255,255,255,0.03); }
.expiring-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.expiring-row-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ============================================================
   Admin · View Client Detail
   ============================================================ */
.vc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.vc-section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.vc-dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 0.75rem;
  align-items: baseline;
}
.vc-dl dt {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.vc-dl dd {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text);
  word-break: break-all;
}
.vc-dl dd code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.05);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}
.usage-bar {
  margin-top: 0.35rem;
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  transition: width 0.4s ease;
}
.usage-bar-fill.success { background: #22c55e; }
.usage-bar-fill.warning { background: #f59e0b; }
.usage-bar-fill.danger  { background: #ef4444; }

/* ============================================================
   HOME / INÍCIO (page-dashboard) — estilo Manychat
   ============================================================ */
.home-header { margin-bottom: 1.5rem; }
.home-greeting {
  font-size: 2.25rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--text);
}
.home-status {
  font-size: 0.95rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.home-status a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.home-status a:hover { text-decoration: underline; }

.home-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.5rem 0 1rem 0;
  color: var(--text);
}

.smart-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.smart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.smart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.smart-card-illustration {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.smart-card-illustration svg {
  width: 80px;
  height: 80px;
  opacity: 0.45;
}
.smart-card-pink   .smart-card-illustration { background: #fdf2f8; color: #be185d; }
.smart-card-purple .smart-card-illustration { background: #f3e8ff; color: #6b21a8; }
.smart-card-green  .smart-card-illustration { background: #ecfdf5; color: #047857; }
.smart-card-yellow .smart-card-illustration { background: #fef9c3; color: #854d0e; }
.smart-card-teal   .smart-card-illustration { background: #ccfbf1; color: #115e59; }
.smart-card-body h4 {
  margin: 0 0 0.4rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.smart-card-body p {
  margin: 0 0 0.75rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.smart-card-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  display: inline-block;
}
.smart-card-link:hover { text-decoration: underline; }
.smart-card-link-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent);
}
.smart-card-link-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smart-card-copy {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.smart-card-copy:hover { background: var(--border); color: var(--text); }
.smart-card-done::after {
  content: '✓';
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.home-templates-section {
  margin-bottom: 2rem;
  padding-top: 1rem;
}
.home-templates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.home-templates-header h3 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.home-templates-link { color: var(--accent); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.home-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.home-template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.home-template-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.home-template-card h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
}
.home-template-card p {
  margin: 0 0 0.75rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.home-template-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.home-insights-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   CONTACTS — layout 2 colunas (sidebar + tabela)
   ============================================================ */
.contacts-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  align-items: flex-start;
}
@media (max-width: 900px) {
  .contacts-layout { grid-template-columns: 1fr; }
}
.contacts-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.contacts-sidebar-section {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.contacts-sidebar-section:last-child { border-bottom: none; }
.contacts-sidebar-section h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.contacts-sidebar-link {
  font-size: 0.7rem;
  color: var(--accent);
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.contacts-sidebar-link:hover { text-decoration: underline; }
.contacts-sidebar-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  list-style: none;
  padding: 0.25rem 0;
}
.contacts-sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.contacts-sidebar-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text);
}
.contacts-sidebar-list li:hover { background: var(--bg); }
.contacts-sidebar-list li.active {
  background: var(--accent);
  color: #fff;
}
.contacts-sidebar-list li.active .cnt { color: rgba(255,255,255,0.85); }
.contacts-sidebar-list .cnt {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.contacts-main { min-width: 0; }

.contacts-bulkbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 0.85rem;
}
.contacts-bulkbar strong { color: #92400e; }
.btn-danger-outline {
  background: transparent;
  border: 1px solid #ef4444;
  color: #ef4444;
}
.btn-danger-outline:hover { background: #ef4444; color: #fff; }
input.contact-check { cursor: pointer; }
.contact-check, #contacts-check-all { width: 16px; height: 16px; accent-color: var(--accent); }

/* ============================================================
   INBOX — filtros, ações no header, tabs, anexos, emojis
   ============================================================ */
.inbox-filters {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}
.inbox-filter-chip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.inbox-filter-chip:hover { background: var(--bg); color: var(--text); }
.inbox-filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.inbox-sort {
  margin-left: auto;
  font-size: 0.78rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.inbox-chat-actions {
  display: flex;
  gap: 4px;
  margin-left: 1rem;
}
.inbox-action-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.inbox-action-btn:hover { background: var(--bg); color: var(--text); border-color: var(--border); }
.inbox-action-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.inbox-compose-tabs {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.inbox-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
}
.inbox-tab:hover { color: var(--text); }
.inbox-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--surface);
}
.inbox-tab-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.inbox-compose-toolbar {
  display: flex;
  gap: 4px;
  padding: 4px 8px 0;
  position: relative;
}
.inbox-tool-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.inbox-tool-btn:hover { background: var(--bg); color: var(--text); }

.emoji-picker {
  position: absolute;
  bottom: 38px;
  left: 8px;
  width: 260px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
}
.emoji-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 4px;
}
.emoji-btn:hover { background: var(--bg); }

.inbox-note {
  background: #fef9c3;
  border-left: 3px solid #eab308;
  padding: 6px 10px;
  margin: 4px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #713f12;
  position: relative;
  max-width: 70%;
  align-self: flex-start;
}
.inbox-note-time {
  display: block;
  font-size: 0.65rem;
  color: #92400e;
  margin-top: 2px;
}

.chat-tag-popover {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  width: 280px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.chat-tag-popover h4 {
  margin: 0 0 8px 0;
  font-size: 0.85rem;
  font-weight: 600;
}
.chat-tag-popover input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.chat-tag-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.btn-warning {
  background: #eab308;
  color: #fff;
  border: none;
}
.btn-warning:hover { background: #ca8a04; }

/* ============================================================
   BROADCAST WIZARD (Mensagem em Massa estilo Manychat)
   ============================================================ */
.broadcast-limit-info {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #065f46;
}
.modal-xl { max-width: 1100px; width: 95vw; }
.broadcast-wizard {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  padding: 1rem 1.5rem 1.5rem;
}
@media (max-width: 900px) {
  .broadcast-wizard { grid-template-columns: 1fr; }
}
.bw-left { display: flex; flex-direction: column; gap: 1rem; }
.bw-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.bw-section summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 1px solid transparent;
}
.bw-section[open] summary { border-bottom-color: var(--border); }
.bw-section-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.bw-cond { margin-bottom: 0.75rem; }
.bw-cond label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.bw-cond-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.bw-tag-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text);
}
.bw-tag-chip:hover { background: var(--surface); }
.bw-tag-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bw-tag-chip .cnt { opacity: 0.7; font-size: 0.7rem; }
.bw-tag-chip.active .cnt { color: rgba(255,255,255,0.85); }

/* PREVIEW iPhone */
.bw-right { display: flex; flex-direction: column; gap: 0.75rem; }
.bw-preview-frame {
  background: linear-gradient(180deg, #075e54 0%, #075e54 60px, #e5ddd5 60px);
  border-radius: 18px;
  border: 8px solid #1a1a1a;
  overflow: hidden;
  min-height: 380px;
  display: flex;
  flex-direction: column;
}
.bw-preview-header {
  background: #075e54;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 500;
}
.bw-preview-body {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #e5ddd5;
}
.bw-preview-msg {
  align-self: flex-start;
  background: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  color: #111;
  max-width: 85%;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}
.bw-preview-msg strong { display: block; margin-bottom: 4px; }

.bw-status-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.bw-status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.bw-status-icon { font-size: 1.1rem; }
.bw-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ============================================================
   FLOWS — Flow Builder Canvas (drag-and-drop visual)
   ============================================================ */
.fb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 1rem 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1rem;
}
.fb-topbar-left, .fb-topbar-right { display: flex; align-items: center; gap: 8px; }

/* Controles de zoom + tamanho do canvas */
.fb-zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 2px 4px;
}
.fb-zoom-controls .fb-zoom-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  width: 26px; height: 26px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: background var(--transition), color var(--transition);
}
.fb-zoom-controls .fb-zoom-btn:hover {
  background: var(--bg3);
  color: var(--text);
}
.fb-zoom-label {
  min-width: 42px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}
.fb-zoom-sep {
  width: 1px;
  height: 16px;
  background: var(--border-light);
  margin: 0 4px;
}
.fb-zoom-controls input[type="range"] {
  width: 80px;
  accent-color: var(--accent);
}
.fb-title { margin: 0; font-size: 1.15rem; font-weight: 600; color: var(--text); }
.fb-icon-btn {
  background: transparent; border: 1px solid var(--border);
  width: 36px; height: 36px; border-radius: 8px;
  color: var(--text); cursor: pointer; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.fb-icon-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.fb-pill {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 500;
}
.fb-pill-on  { background: rgba(34,197,94,0.18); color: #4ade80; border: 1px solid rgba(34,197,94,0.4); }
.fb-pill-off { background: rgba(148,163,184,0.12); color: var(--text2); border: 1px solid var(--border); }

.fb-workspace {
  display: grid;
  grid-template-columns: 200px 1fr 340px;
  gap: 1rem;
  height: calc(100vh - 200px);
  min-height: 500px;
}
@media (max-width: 1300px) {
  .fb-workspace { grid-template-columns: 180px 1fr 300px; }
}
@media (max-width: 1100px) {
  .fb-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }
  .fb-palette {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    max-height: 80px;
    padding: 0.5rem;
  }
  .fb-palette-section { display: flex; align-items: center; margin: 0 0.5rem 0 0; }
  .fb-palette-section h5 { display: none; }
  .fb-tool { white-space: nowrap; }
  /* Drawer vira overlay (modal-like) quando step selecionado */
  .fb-drawer {
    position: fixed;
    right: 0; top: 0; bottom: 0;
    width: min(90vw, 400px);
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: -4px 0 12px rgba(0,0,0,0.4);
  }
  .fb-drawer.fb-drawer-open { transform: translateX(0); }
  .fb-canvas-wrap { min-height: 60vh; }
}

.fb-palette {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.75rem 0.5rem;
  overflow-y: auto;
}
.fb-palette-section { margin-bottom: 1rem; }
.fb-palette-section h5 {
  margin: 0 0 0.5rem 0;
  padding: 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
}
.fb-tool {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  margin-bottom: 2px;
}
.fb-tool:hover { background: var(--bg-hover); border-color: var(--border-light); }
.fb-tool-ico {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.fb-canvas-wrap {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: auto;
  background-image: radial-gradient(circle at 12px 12px, rgba(148,163,184,0.18) 1px, transparent 1.5px);
  background-size: 24px 24px;
}
.fb-canvas {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  width: 2400px;
  height: 1800px;
  transform-origin: 0 0;
  transform: scale(var(--fb-zoom, 1));
  transition: transform 0.12s ease-out;
}
.fb-connectors {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  /* NAO aplicar transform: o pai (.fb-canvas) ja faz scale; aplicar aqui escala 2x */
}
.fb-connectors .fb-link-hit { pointer-events: stroke; }
.fb-canvas-hint {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text2);
  text-align: center;
  pointer-events: none;
  font-size: 0.95rem;
}
.fb-canvas-hint small { display: block; margin-top: 8px; color: var(--text-muted); font-size: 0.78rem; }

.fb-card {
  position: absolute;
  width: var(--fb-card-w, 220px);
  background: var(--bg2);
  border: 2px solid var(--border-light);
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.25);
  z-index: 2;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fb-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.25), 0 4px 12px rgba(0,0,0,0.3);
}
.fb-card:hover {
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.fb-card-header {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border-radius: 8px 8px 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.35);
  cursor: grab;
}
.fb-card-ico { font-size: 1rem; flex: 0 0 auto; }
.fb-card-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fb-card-subtitle {
  flex: 0 1 auto;
  font-size: 0.62rem;
  font-weight: 500;
  opacity: 0.78;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 4px;
  min-width: 0;
  text-shadow: 0 1px 1px rgba(0,0,0,0.35);
}
.fb-step-label-row {
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--border-light);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
}
.fb-card-x {
  background: rgba(0,0,0,0.25);
  border: none;
  color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}
.fb-card-x:hover { background: rgba(239,68,68,0.85); opacity: 1; }
.fb-card-body {
  padding: 8px;
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.4;
  cursor: pointer;
  word-break: break-word;
  background: linear-gradient(180deg, #d9dbd4 0%, #d2d6c8 100%);
  min-height: 44px;
  position: relative;
}
:root[data-theme="dark"] .fb-card-body,
.dark .fb-card-body,
body.theme-dark .fb-card-body { background: linear-gradient(180deg, #0b141a 0%, #0a1217 100%); }

/* Bolha de mensagem (estilo WhatsApp incoming/business) */
.fb-prev-bubble {
  background: #ffffff;
  color: #111;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
  max-width: 100%;
  word-wrap: break-word;
}
:root[data-theme="dark"] .fb-prev-bubble,
.dark .fb-prev-bubble,
body.theme-dark .fb-prev-bubble { background: #202c33; color: #e9edef; }

.fb-prev-bubble-img { padding: 4px; }
.fb-prev-img {
  width: 100%;
  height: 90px;
  background-size: cover;
  background-position: center;
  background-color: rgba(0,0,0,0.08);
  border-radius: 4px;
}
.fb-prev-bubble-ai { border-left: 3px solid #a855f7; }

.fb-prev-btn-sep {
  margin: 6px -4px 4px;
  border-top: 1px solid rgba(0,0,0,0.08);
}
:root[data-theme="dark"] .fb-prev-btn-sep,
.dark .fb-prev-btn-sep,
body.theme-dark .fb-prev-btn-sep { border-top-color: rgba(255,255,255,0.08); }

.fb-prev-btn {
  display: block;
  text-align: center;
  padding: 6px 8px;
  background: rgba(0,0,0,0.02);
  border-radius: 4px;
  font-size: 0.75rem;
  color: #00a884;
  font-weight: 600;
  margin: 2px 0;
}
:root[data-theme="dark"] .fb-prev-btn,
.dark .fb-prev-btn,
body.theme-dark .fb-prev-btn { background: rgba(255,255,255,0.04); color: #53bdeb; }
.fb-prev-btn-link::after { content: ' ↗'; opacity: 0.7; font-weight: 400; }

.fb-prev-chip {
  background: var(--bg-soft);
  border: 1px dashed var(--border-light);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.fb-prev-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 6px;
}

/* ============================================================
   AGENDA — Calendar view (visão semanal)
   Variavel CSS centraliza grid pra header+body alinharem perfeito.
   ============================================================ */
.agenda-cal-wrap {
  --agenda-grid: 60px repeat(7, minmax(0, 1fr));
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(--bg2);
  overflow: hidden;
}
.agenda-cal-grid-header {
  display: grid;
  grid-template-columns: var(--agenda-grid);
  border-bottom: 1px solid var(--border-light);
}
.agenda-cal-hcol {
  padding: 10px 4px;
  text-align: center;
  border-right: 1px solid var(--border-soft, var(--border-light));
  min-width: 0;
}
.agenda-cal-hcol:first-child,
.agenda-cal-hcol:last-child { border-right: none; }
.agenda-cal-hcol.is-today { background: rgba(34,197,94,0.08); }
.agenda-cal-hcol.is-today > div:last-child { color: #22c55e; }

.agenda-cal-allday {
  display: grid;
  grid-template-columns: var(--agenda-grid);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-soft);
}
.agenda-cal-allday-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 4px 6px;
  text-align: right;
  align-self: center;
}
.agenda-cal-allday-cell {
  padding: 4px;
  border-right: 1px solid var(--border-soft, var(--border-light));
  min-height: 24px;
  min-width: 0;
}
.agenda-cal-allday-cell:last-child { border-right: none; }

/* Body: mesmo grid de 8 colunas. .agenda-cal-hours ocupa col 1 + linhas inteiras. */
.agenda-cal-body {
  display: grid;
  grid-template-columns: var(--agenda-grid);
  max-height: 600px;
  overflow-y: auto;
  position: relative;
  scrollbar-gutter: stable;
}
.agenda-cal-hours {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-light);
}
.agenda-cal-hour-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 2px 6px 0;
  text-align: right;
  position: relative;
  top: -7px;
}
.agenda-cal-day-col {
  position: relative;
  border-right: 1px solid var(--border-soft, var(--border-light));
  min-width: 0;
}
.agenda-cal-day-col:last-child { border-right: none; }
.agenda-cal-day-col.is-today { background: rgba(34,197,94,0.04); }

/* Reserva slot para scrollbar tambem no header pra alinhar com body */
@supports (scrollbar-gutter: stable) {
  .agenda-cal-grid-header,
  .agenda-cal-allday {
    scrollbar-gutter: stable;
  }
}
.agenda-cal-hour-line {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px solid var(--border-soft, var(--border-light));
  pointer-events: none;
}

/* Eventos posicionados absolutamente dentro da day-col da grade de horas */
.agenda-cal-day-col .agenda-cal-event {
  position: absolute;
  left: 2px; right: 2px;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  line-height: 1.25;
  overflow: hidden;
  cursor: pointer;
  color: #fff;
  white-space: normal;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: filter 0.15s;
}
.agenda-cal-day-col .agenda-cal-event:hover { filter: brightness(1.1); z-index: 2; }

/* Eventos no all-day: ficam no fluxo, não absolute */
.agenda-cal-allday-cell .agenda-cal-event {
  position: static;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  line-height: 1.3;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  margin-bottom: 2px;
}
.agenda-cal-event-booking { background: #22c55e; }
.agenda-cal-event-test { background: #94a3b8; }
.agenda-cal-event-google { background: #3b82f6; }

.agenda-cal-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-soft);
  font-size: 0.82rem;
  color: var(--text);
  flex-wrap: wrap;
}
.legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* Visão MÊS */
.agenda-month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-soft);
}
.agenda-month-hcol {
  padding: 8px;
  text-align: center;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-right: 1px solid var(--border-soft, var(--border-light));
}
.agenda-month-hcol:last-child { border-right: none; }

.agenda-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.agenda-month-cell {
  border-right: 1px solid var(--border-soft, var(--border-light));
  border-bottom: 1px solid var(--border-soft, var(--border-light));
  padding: 6px;
  cursor: pointer;
  background: var(--bg2);
  min-height: 96px;
  overflow: hidden;
}
.agenda-month-cell:hover { background: var(--bg3); }
.agenda-month-cell.is-out { background: var(--bg-soft); opacity: 0.55; }
.agenda-month-cell.is-today { background: rgba(34,197,94,0.06); }
.agenda-month-cell.is-today .agenda-month-daynum {
  background: #22c55e; color: #fff; border-radius: 50%; width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.82rem;
}
.agenda-month-daynum {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.agenda-month-event {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  margin-bottom: 2px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.agenda-month-event.agenda-cal-event-booking { background: #22c55e; }
.agenda-month-event.agenda-cal-event-test { background: #94a3b8; }
.agenda-month-event.agenda-cal-event-google { background: #3b82f6; }
.agenda-month-more {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  padding-left: 4px;
}

.fb-port {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  transition: all 0.15s;
}
.fb-port::before {
  content: '';
  position: absolute;
  inset: -8px;  /* hit area maior pra toque/mouse */
}
.fb-port-in  { top: -10px; }
.fb-port-out { bottom: -10px; cursor: crosshair; }
.fb-port-out:hover, .fb-port-out:active {
  background: var(--accent);
  transform: translateX(-50%) scale(1.25);
}
.fb-card.selected .fb-port { background: var(--accent); }

/* Portas por botao (verde) e por row (roxo) — numeradas */
.fb-port-btn, .fb-port-row {
  bottom: -10px;
  cursor: crosshair;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  width: 18px;
  height: 18px;
}
.fb-port-btn {
  background: #10b981;
  border-color: #10b981;
}
.fb-port-row {
  background: #8b5cf6;
  border-color: #8b5cf6;
}
.fb-port-btn:hover, .fb-port-row:hover {
  transform: translateX(-50%) scale(1.3);
  filter: brightness(1.15);
}

/* Caption embaixo da porta — mostra o titulo do botao/opcao
   pra deixar claro que cada porta corresponde a uma opcao especifica */
.fb-port-cap {
  position: absolute;
  bottom: -32px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.55);
  border: 1px solid transparent;
  pointer-events: none;
  z-index: 2;
  letter-spacing: 0.01em;
}
.fb-port-cap-btn { color: #10b981; border-color: rgba(16,185,129,0.35); }
.fb-port-cap-row { color: #c4b5fd; border-color: rgba(139,92,246,0.4); }

/* Card precisa de margem-extra embaixo pra captions nao sobreporem o proximo card */
.fb-card:has(.fb-port-cap) { padding-bottom: 22px; }

/* Hint visual no drawer dos blocos buttons/list — orienta sobre conectores arrastaveis */
.fb-drag-hint {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-left: 3px solid #22c55e;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text2);
  line-height: 1.5;
}
.fb-hint-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  margin: 0 2px;
}
.fb-hint-dot-btn { background: #10b981; border: 2px solid #10b981; }
.fb-hint-dot-row { background: #8b5cf6; border: 2px solid #8b5cf6; }

/* Conexoes SVG: hit area invisivel + cursor pointer pra deletar */
.fb-connectors .fb-link-hit { cursor: pointer; }
.fb-connectors .fb-link-hit:hover + .fb-link { stroke-width: 3; filter: drop-shadow(0 0 4px currentColor); }

.fb-drawer {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1rem;
  overflow-y: auto;
}
.fb-drawer-empty {
  color: var(--text2);
  font-size: 0.9rem;
  text-align: center;
  padding-top: 2rem;
}
.fb-drawer-empty a { color: var(--accent); text-decoration: none; }
.fb-drawer-empty a:hover { text-decoration: underline; }
.fb-drawer-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 1rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}
.fb-drawer-cat {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.fb-drawer-header h4 { margin: 0; font-size: 1rem; color: var(--text); }
.fb-drawer-content .form-label {
  display: block;
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 4px;
}
.fb-drawer-content .form-input, .fb-drawer-content .form-select {
  width: 100%;
}
.fb-drawer-content textarea.form-input {
  resize: vertical;
  font-family: inherit;
}
.fb-drawer-actions {
  display: flex; gap: 8px;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

/* Blocos de gatilho (trigger primario + extras) */
.fb-trigger-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.fb-trigger-block + .fb-trigger-block { margin-top: 0; }
.fb-trigger-block h5 { color: var(--text-muted); }
.fb-trigger-block .form-label:first-of-type { margin-top: 0; }

/* Upload de imagem no bloco "image" do flow */
.img-upload-zone {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.img-upload-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg2);
}
.img-upload-placeholder {
  width: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 1.8rem;
  background: var(--bg2);
  border-radius: 6px;
}
.img-upload-placeholder small {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.img-upload-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}
.img-upload-actions .btn {
  flex: 1;
  text-align: center;
  justify-content: center;
}

/* Bloco visual agrupando botao + select de roteamento por botao/row */
.fb-btn-row {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 10px 12px 12px;
  margin-top: 12px;
}
.fb-btn-row .form-label { margin-top: 0; }
.fb-btn-row .form-label + .form-input { margin-bottom: 0; }

/* ============================================================
   WHATSAPP PREVIEW (drawer)
   ============================================================ */
.wa-preview {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-light);
}
.wa-preview-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.wa-phone {
  background: #0b141a; /* preto-azulado do WA dark */
  background-image:
    radial-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    radial-gradient(rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 14px 14px, 7px 7px;
  background-position: 0 0, 7px 3px;
  border-radius: 12px;
  border: 1px solid #0a1820;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.wa-phone-header {
  background: #1f2c33;
  color: #e9edef;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid #131c22;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wa-phone-header::before {
  content: '👤';
  display: inline-block;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #6b7c85;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.wa-phone-body {
  padding: 12px 10px 14px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wa-bubble {
  align-self: flex-start;
  max-width: 88%;
  background: #202c33; /* balao recebido (cliente recebe do business) */
  color: #e9edef;
  padding: 7px 10px 18px;
  border-radius: 0 8px 8px 8px;
  font-size: 0.85rem;
  line-height: 1.35;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 0 rgba(0,0,0,0.13);
}
.wa-bubble::before {
  content: '';
  position: absolute;
  top: 0; left: -6px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 6px 6px 0;
  border-color: transparent #202c33 transparent transparent;
}
.wa-bubble-img {
  padding: 4px 4px 18px;
  max-width: 75%;
}
.wa-bubble-img img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.wa-img-placeholder {
  width: 100%;
  min-height: 120px;
  background: #2a3942;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #8696a0;
  font-size: 0.85rem;
}
.wa-cap {
  padding: 6px 6px 0;
  font-size: 0.85rem;
}
.wa-time {
  position: absolute;
  right: 8px;
  bottom: 3px;
  font-size: 0.65rem;
  color: #8696a0;
}
.wa-btns {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
  background: #2a3942;
  border-radius: 8px;
  overflow: hidden;
  max-width: 95%;
  align-self: flex-start;
}
.wa-btn {
  background: #2a3942;
  color: #00a884; /* verde WhatsApp para botao interativo */
  border: none;
  padding: 9px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: default;
  text-align: center;
  border-bottom: 1px solid #1f2c33;
}
.wa-btn:last-child { border-bottom: none; }
.wa-btn-empty {
  color: #6b7c85;
  font-style: italic;
  font-weight: 400;
}
.wa-btn-list { color: #00a884; }
.wa-btn-cta { color: #53bdeb; } /* azul WhatsApp para CTA URL */
.wa-list-preview {
  align-self: flex-start;
  max-width: 95%;
  background: #1f2c33;
  border-radius: 8px;
  padding: 4px 0;
  margin-top: 4px;
}
.wa-list-row {
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #e9edef;
  border-bottom: 1px solid #131c22;
}
.wa-list-row:last-child { border-bottom: none; }
.wa-list-row.wa-empty { color: #6b7c85; font-style: italic; }

/* ============================================================
   FLOW SIMULATOR (mini celular)
   ============================================================ */
.sim-modal { max-width: 760px; width: 95vw; }
.sim-toolbar {
  display: flex;
  gap: 8px;
  padding: 0.85rem 1.5rem;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}
.sim-toolbar-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.sim-toolbar-chip:hover { background: var(--bg3); }
.sim-toolbar-chip input { margin: 0; }
.sim-toolbar-chip-accent {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.4);
  color: #c084fc;
  font-weight: 600;
}
.sim-toolbar-chip-accent:hover { background: rgba(168, 85, 247, 0.18); }
.sim-body {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  padding: 1rem 1.5rem 1.5rem;
}
@media (max-width: 720px) {
  .sim-body { grid-template-columns: 1fr; }
}

/* Celular fake */
.sim-phone {
  background: #0b141a;
  border-radius: 28px;
  border: 8px solid #1a1a1a;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), inset 0 0 0 1px #2a2a2a;
  display: flex;
  flex-direction: column;
  height: 520px;
  position: relative;
  overflow: hidden;
}
.sim-phone-notch {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 80px; height: 14px;
  background: #1a1a1a;
  border-radius: 0 0 12px 12px;
  z-index: 5;
}
.sim-phone-header {
  background: #1f2c33;
  padding: 18px 14px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #131c22;
}
.sim-phone-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.sim-phone-name {
  color: #e9edef;
  font-weight: 600;
  font-size: 0.92rem;
}
.sim-phone-status {
  color: #00a884;
  font-size: 0.7rem;
}
.sim-phone-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background:
    radial-gradient(rgba(255,255,255,0.018) 1px, transparent 1px) 0 0 / 14px 14px,
    #0b141a;
}
.sim-phone-body::-webkit-scrollbar { width: 4px; }
.sim-phone-body::-webkit-scrollbar-thumb { background: #2a3942; border-radius: 2px; }
.sim-empty {
  color: #6b7c85;
  font-size: 0.82rem;
  text-align: center;
  padding: 1.5rem 1rem;
  font-style: italic;
}
.sim-phone-input {
  background: #1f2c33;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #131c22;
}
.sim-phone-input input {
  flex: 1;
  background: #2a3942;
  border: none;
  border-radius: 18px;
  padding: 8px 14px;
  color: #e9edef;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}
.sim-phone-input input::placeholder { color: #6b7c85; }
.sim-send-btn {
  background: #00a884;
  color: #fff;
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  transition: filter var(--transition);
}
.sim-send-btn:hover { filter: brightness(1.1); }

/* Mensagens */
.sim-msg { display: flex; flex-direction: column; width: 100%; }
.sim-msg-out { align-items: flex-end; }
.sim-msg-in  { align-items: flex-start; }
.sim-msg-system { align-items: center; }

.sim-bubble {
  max-width: 85%;
  padding: 7px 10px 18px;
  font-size: 0.85rem;
  line-height: 1.35;
  color: #e9edef;
  border-radius: 8px;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 0 rgba(0,0,0,0.13);
}
.sim-bubble-in {
  background: #202c33;
  border-radius: 0 8px 8px 8px;
}
.sim-bubble-in::before {
  content: '';
  position: absolute; top: 0; left: -6px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 6px 6px 0;
  border-color: transparent #202c33 transparent transparent;
}
.sim-bubble-out {
  background: #005c4b;
  border-radius: 8px 0 8px 8px;
}
.sim-bubble-out::before {
  content: '';
  position: absolute; top: 0; right: -6px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 0 6px 6px;
  border-color: transparent transparent transparent #005c4b;
}
.sim-bubble-img { padding: 4px 4px 18px; max-width: 70%; }
.sim-bubble-img img {
  width: 100%; max-height: 160px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.sim-cap { padding: 6px 6px 0; font-size: 0.85rem; }
.sim-time {
  position: absolute; right: 8px; bottom: 3px;
  font-size: 0.65rem; color: #8696a0;
}

/* Botoes interativos clicaveis */
.sim-int-btns {
  align-self: flex-start;
  max-width: 95%;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: #2a3942;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 4px;
}
.sim-int-btn {
  background: #2a3942;
  color: #00a884;
  border: none;
  padding: 9px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  border-bottom: 1px solid #1f2c33;
  font-family: inherit;
  text-decoration: none;
  display: block;
  transition: background var(--transition);
}
.sim-int-btn:last-child { border-bottom: none; }
.sim-int-btn:hover { background: #324049; }
.sim-cta-btn { color: #53bdeb; }

.sim-list {
  align-self: flex-start;
  max-width: 95%;
  background: #1f2c33;
  border-radius: 8px;
  padding: 4px 0;
  margin-top: 4px;
}
.sim-list-row {
  padding: 9px 12px;
  font-size: 0.82rem;
  color: #e9edef;
  cursor: pointer;
  border-bottom: 1px solid #131c22;
  transition: background var(--transition);
}
.sim-list-row:last-child { border-bottom: none; }
.sim-list-row:hover { background: #2a3942; }
.sim-list-row small {
  display: block;
  font-size: 0.7rem;
  color: #8696a0;
  margin-top: 2px;
}

.sim-sysmsg {
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 12px;
  text-align: center;
  font-style: italic;
  max-width: 92%;
}

/* Lateral do simulador */
.sim-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sim-help {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.82rem;
}

/* ============================================================
   CENTRAL DE AJUDA
   ============================================================ */
.help-header {
  text-align: center;
  padding: 2rem 1rem 1.75rem;
  background: linear-gradient(135deg, rgba(14,165,233,0.12) 0%, rgba(168,85,247,0.08) 100%), var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.help-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 0%, rgba(14,165,233,0.15), transparent 50%);
  pointer-events: none;
}
.help-header > * { position: relative; }
.help-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.help-tagline {
  color: var(--text2);
  margin: 0 0 1.25rem 0;
  font-size: 0.95rem;
}
.help-search-wrap { max-width: 560px; margin: 0 auto; }
.help-search {
  width: 100%;
  padding: 12px 18px;
  border: 1px solid var(--border-light);
  border-radius: 28px;
  font-size: 0.92rem;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.help-search::placeholder { color: var(--text-muted); }
.help-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25), 0 0 0 3px var(--accent-light);
}

.help-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: flex-start;
}
@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
}
.help-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.help-cat { margin-bottom: 0.75rem; }
.help-cat-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.25rem;
}
.help-cat ul { list-style: none; margin: 0; padding: 0; }
.help-cat li { margin: 0; }
.help-cat li a {
  display: block;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
}
.help-cat li a:hover { background: var(--bg); }
.help-cat li.active a {
  background: var(--accent);
  color: #fff;
}

.help-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  min-height: 400px;
}
.help-home h3 {
  font-size: 1.1rem;
  margin: 0 0 1rem 0;
}
.help-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.help-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg);
}
.help-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}
.help-card-icon {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 0.5rem;
}
.help-card h4 { margin: 0 0 0.25rem; font-size: 0.95rem; font-weight: 600; }
.help-card p { margin: 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }

.help-faq details {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg);
}
.help-faq summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
}
.help-faq details[open] summary { margin-bottom: 0.5rem; }
.help-faq details p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.help-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.help-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}
.help-breadcrumb a:hover { text-decoration: underline; }
.help-breadcrumb span { color: var(--text-muted); }

.help-article h2 {
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
  font-weight: 700;
}
.help-article h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.help-article p, .help-article li {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text);
}
.help-article ul, .help-article ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.help-article li { margin-bottom: 0.35rem; }
.help-article code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.85rem;
  font-family: monospace;
  color: #be185d;
}
.help-article a {
  color: var(--accent);
  text-decoration: underline;
}

/* ============================================================
   RESPONSIVIDADE — refinamentos para componentes recentes
   ============================================================ */

/* Modais ocupam tela toda em mobile */
@media (max-width: 720px) {
  .modal-overlay { padding: 0; }
  .modal {
    max-width: 100% !important;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  .modal-header { padding: 0.85rem 1rem; }
  .modal-header h3 { font-size: 1rem; }
  .modal-body { padding: 1rem; }
  .modal-footer {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .modal-footer .btn { flex: 1; min-width: 0; }
}

/* Agenda — visão semana em mobile vira lista vertical (grid 7 colunas fica inutilizavel) */
@media (max-width: 720px) {
  .agenda-cal-grid-header,
  .agenda-cal-allday {
    grid-template-columns: 50px repeat(7, minmax(70px, 1fr));
    overflow-x: auto;
  }
  .agenda-cal-body {
    grid-template-columns: 50px 1fr;
  }
  .agenda-cal-days {
    grid-template-columns: repeat(7, minmax(70px, 1fr));
    overflow-x: auto;
  }
  .agenda-cal-event { font-size: 0.62rem; padding: 2px 4px; }
  .agenda-cal-hour-label { font-size: 0.62rem; }

  /* Visão mês: cells menores */
  .agenda-month-cell { min-height: 70px; padding: 3px; }
  .agenda-month-daynum { font-size: 0.78rem; }
  .agenda-month-event { font-size: 0.62rem; padding: 1px 3px; }
  .agenda-month-more { font-size: 0.62rem; }
  .agenda-month-hcol { font-size: 0.65rem; padding: 6px 2px; }
}

/* Toolbar da agenda quebra cedo se botões + dropdown não couberem */
@media (max-width: 720px) {
  #page-agenda .page-header,
  #page-agenda > div:has(h3) {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
}

/* Editor de serviço — 2 colunas viram 1 em mobile */
@media (max-width: 720px) {
  #_svc_editor .modal-body > section > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

/* Card do flow no canvas: tamanho minimo em telas pequenas (não quebrar texto preview) */
@media (max-width: 720px) {
  .fb-card { min-width: 160px; }
  .fb-card-body { font-size: 0.72rem; }
}

/* Simulador: em mobile o telefone + dicas viram coluna */
@media (max-width: 720px) {
  .sim-body { flex-direction: column !important; }
  .sim-phone, .sim-side { width: 100% !important; max-width: 100%; }
  .sim-side { padding-top: 12px; border-top: 1px solid var(--border-light); }
}

/* Tabelas que viram lista cards em mobile */
@media (max-width: 720px) {
  .table-container { overflow-x: auto; }
  .table-container table { min-width: 560px; }
}

/* Ajustes de contraste extra: garantir que badges/links em backgrounds claros não fiquem ilegiveis */
.badge { color: #fff; }
.badge-muted { background: var(--text-muted); color: #fff; }
.badge-success { background: #22c55e; color: #fff; }
.badge-info { background: #3b82f6; color: #fff; }
.badge-warning { background: #f59e0b; color: #fff; }
.badge-danger { background: #ef4444; color: #fff; }

/* Botões muito pequenos: garantir minimo legível */
.btn-xs {
  padding: 3px 8px;
  font-size: 0.72rem;
}

/* Sidebar e header em mobile devem ter um pouco mais de respiro */
@media (max-width: 720px) {
  .hamburger { top: 10px; left: 10px; }
}

/* ============================================================
   COMPONENTES PADRONIZADOS — segmented toggle, card-with-header,
   form-with-preview. Resultado da auditoria visual 2026-05-18.
   ============================================================ */

/* Segmented toggle (Semana/Mês, etc) — substitui hacks de inline border */
.seg-toggle {
  display: inline-flex;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  height: 32px;
}
.seg-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 0.82rem;
  padding: 0 14px;
  cursor: pointer;
  height: 100%;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.seg-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border-light);
}
.seg-toggle-btn:hover { background: var(--bg-hover); color: var(--text); }
.seg-toggle-btn.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Card com header bar (ex: Contatos no grupo, Agentes Vinculados) */
.card-with-header {
  padding: 0 !important;
  overflow: hidden;
}
.card-with-header-bar {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg2);
}
.card-with-header-body {
  max-height: 400px;
  overflow-y: auto;
  padding: 0;
}
.card-with-header-body .empty-state p { color: var(--text2); }

/* Form com preview lateral (modal templates) */
.form-with-preview {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
}
@media (max-width: 900px) {
  .form-with-preview { grid-template-columns: 1fr; }
}

/* Padronização de empty-state p (texto de fundo de listas vazias) */
.empty-state p { color: var(--text2); font-size: 0.88rem; line-height: 1.45; }

/* Banners de aviso uniformes */
.warn-banner, .info-banner, .success-banner {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
}
.warn-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
}
.info-banner {
  background: rgba(14, 165, 233, 0.10);
  border: 1px solid rgba(14, 165, 233, 0.3);
  color: var(--text);
}
.success-banner {
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--text);
}

/* Helper class .hidden (substitui style="display:none" inline) */
.hidden { display: none !important; }

/* Section headers dentro da página Agenda — padrão consistente */
#page-agenda h3 { margin: 1.5rem 0 0.75rem; font-size: 1.05rem; }
#page-agenda h3:first-of-type { margin-top: 0; }

/* Card .card baseline — garante padding consistente */
.card { transition: border-color 0.15s, box-shadow 0.15s; }
.card .card-with-header-bar { background: transparent; }

/* Detalhes/summary com hover state */
details > summary { cursor: pointer; transition: color 0.15s; }
details > summary:hover { color: var(--accent); }

/* Card-value (KPI) — fix tier-card font misaligned */
.card-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.card-value.tier-card-value { font-size: 1.25rem; }  /* tier text é mais longo, mas continua proporcional */

/* =====================================================================
   Responsividade mobile — grids 2-col viram 1-col, sticky vira static.
   Adicionado em 2026-05-27 numa varredura de UI/UX bugs.
   ===================================================================== */
@media (max-width: 768px) {
  /* AI Agent editor: grid 2-col vira 1-col, simulador deixa de ser sticky */
  .ai-agent-editor-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .ai-agent-simulator { position: static !important; max-height: none !important; }

  /* Form groups com grid 2-col (temperatura/max-tokens etc) viram coluna única */
  .form-grid-2 { grid-template-columns: 1fr !important; }

  /* Drawer de notas inbox: em telas <500px ocupa 100% pra leitura confortável */
  #inbox-notes-drawer { width: 100% !important; max-width: 100% !important; }

  /* Tabela de bookings/contatos: garante scroll horizontal em vez de overflow */
  .table-container, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Tabela: esconde colunas secundárias em mobile (Agenda, Engajamento) */
  .col-hide-md { display: none !important; }
}

@media (max-width: 480px) {
  /* Tabela: esconde ainda mais colunas em telas muito estreitas (Última Interação, Tags) */
  .col-hide-sm { display: none !important; }
}
