    :root {
      --primary:        #3b82f6;
      --primary-hover:  #2563eb;
      --primary-light:  #eff6ff;
      --primary-ring:   rgba(59,130,246,0.2);
      --nav-bg:         #0f172a;
      --nav-width:      64px;
      --sidebar-w:      320px;
      --sidebar-bg:     #ffffff;
      --main-bg:        #f1f5f9;
      --card-bg:        #ffffff;
      --text:           #0f172a;
      --text-muted:     #64748b;
      --text-xs:        #94a3b8;
      --border:         #e2e8f0;
      --shadow:         0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
      --shadow-md:      0 4px 6px -1px rgba(0,0,0,0.10), 0 2px 4px -1px rgba(0,0,0,0.06);
      --green-ok:       #22c55e;
      --red-err:        #ef4444;
      --bubble-in:      #ffffff;
      --bubble-out:     var(--primary);
      --bubble-out-txt: #ffffff;
    }
    *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
    html, body { height: 100%; overflow: hidden; }
    body { font-family: 'Inter', sans-serif; color: var(--text); background: var(--main-bg); display: flex; }

    /* ── APP SHELL ───────────────────────────────────────────────── */
    .app { display: flex; width: 100%; height: 100vh; overflow: hidden; }

    /* ── NAV RAIL ────────────────────────────────────────────────── */
    .nav-rail {
      width: var(--nav-width); flex-shrink: 0;
      background: var(--nav-bg);
      display: flex; flex-direction: column; align-items: center;
      padding: 0; z-index: 200;
    }
    .nav-brand {
      height: 64px; width: 100%; display: flex; align-items: center; justify-content: center;
      border-bottom: 1px solid rgba(255,255,255,0.06); flex-shrink: 0;
    }
    .nav-brand span { font-size: 22px; }
    .nav-items { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 4px; width: 100%; }
    .nav-btn {
      width: 44px; height: 44px; border: none; background: transparent;
      color: #94a3b8; border-radius: 10px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: all 0.15s; position: relative;
    }
    .nav-btn:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
    .nav-btn.active { background: var(--primary); color: #ffffff; }
    .nav-btn svg { width: 20px; height: 20px; }
    .nav-bottom { padding: 16px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
    .status-dot {
      width: 10px; height: 10px; border-radius: 50%;
      border: 2px solid rgba(255,255,255,0.15);
    }
    .status-dot.online { background: var(--green-ok); }
    .status-dot.offline { background: var(--red-err); }

    /* ── SIDEBAR ─────────────────────────────────────────────────── */
    .sidebar {
      width: var(--sidebar-w); flex-shrink: 0;
      background: #f4f7fb;
      border-right: 2px solid #dce4ef;
      box-shadow: 3px 0 10px rgba(0,0,0,0.07);
      display: flex; flex-direction: column; overflow: hidden;
      position: relative; z-index: 10;
    }
    .sidebar-hdr {
      height: 64px; padding: 0 16px;
      display: flex; align-items: center; justify-content: space-between;
      background: #edf1f9;
      border-bottom: 2px solid #dce4ef; flex-shrink: 0;
    }
    .sidebar-hdr h2 { font-size: 16px; font-weight: 700; color: var(--text); }
    .sidebar-search {
      padding: 10px 12px; border-bottom: 1px solid #dce4ef; flex-shrink: 0;
      background: #f4f7fb;
    }
    .sidebar-search input {
      width: 100%; padding: 8px 12px;
      background: #fff; border: 1px solid #c9d4e4;
      border-radius: 8px; font-size: 13px; font-family: inherit;
      color: var(--text); outline: none; transition: border-color 0.15s;
    }
    .sidebar-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

    /* Conversation list */
    #conversationList, #patientList { flex: 1; overflow-y: auto; }
    .conv-item {
      display: flex; align-items: center; gap: 10px; padding: 12px 14px;
      cursor: pointer; border-bottom: 1px solid #dce4ef; transition: background 0.1s;
    }
    .conv-item:hover { background: #e8eef8; }
    .conv-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
    .conv-item.bot-on  { border-left: 3px solid #8b5cf6; }
    .conv-item.human-on { border-left: 3px solid #14b8a6; }
    .conv-tabs { display: flex; flex-shrink: 0; background: #f4f7fb; border-bottom: 2px solid #dce4ef; }
    .conv-tab { flex: 1; padding: 8px 4px; border: none; background: transparent; font-size: 11.5px; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all 0.15s; border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit; }
    .conv-tab:hover { color: var(--text); background: #edf1f9; }
    .conv-tab.active { color: var(--primary); font-weight: 700; border-bottom-color: var(--primary); background: #fff; }
    .conv-avatar {
      width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
      background: linear-gradient(135deg, var(--primary), var(--primary-hover));
      color: white; display: flex; align-items: center; justify-content: center;
      font-size: 16px; font-weight: 700;
    }
    .conv-body { flex: 1; min-width: 0; }
    .conv-name { font-size: 13px; font-weight: 600; color: var(--text); }
    .conv-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
    .conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
    .conv-time { font-size: 11px; color: var(--text-xs); }
    .unread-badge {
      min-width: 18px; height: 18px; background: var(--primary); color: white;
      border-radius: 20px; font-size: 10px; font-weight: 700;
      display: flex; align-items: center; justify-content: center; padding: 0 5px;
    }
    .empty-list { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
    .empty-list-icon { font-size: 36px; margin-bottom: 10px; }

    /* Patient list */
    .patient-card {
      display: flex; align-items: center; gap: 12px; padding: 12px 14px;
      border-bottom: 1px solid #f8fafc;
    }
    .patient-avatar {
      width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
      background: linear-gradient(135deg, #8b5cf6, #6d28d9);
      color: white; display: flex; align-items: center; justify-content: center;
      font-size: 16px; font-weight: 700;
    }
    .patient-info { flex: 1; min-width: 0; }
    .patient-name { font-size: 13px; font-weight: 600; color: var(--text); }
    .patient-detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
    .patient-phone { font-size: 11px; color: var(--text-muted); }

    /* Config sidebar nav */
    .config-sidenav { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
    .config-sidenav-btn {
      width: 100%; text-align: left; padding: 10px 12px; border: none; background: transparent;
      border-radius: 8px; font-size: 13px; font-family: inherit; color: var(--text-muted);
      cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 8px;
    }
    .config-sidenav-btn:hover { background: var(--main-bg); color: var(--text); }
    .config-sidenav-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
    .config-sidenav-footer { padding: 12px; border-top: 1px solid var(--border); }
    .btn-primary {
      width: 100%; padding: 10px; background: var(--primary); color: white;
      border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
      font-family: inherit; cursor: pointer; transition: background 0.15s;
    }
    .btn-primary:hover { background: var(--primary-hover); }
    .config-saved { display: none; text-align: center; font-size: 12px; font-weight: 600; color: var(--green-ok); margin-top: 8px; }

    /* Bot sidebar */
    .bot-sidenav { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
    .bot-status-card {
      background: var(--main-bg); border-radius: 12px; padding: 16px; text-align: center;
    }
    .bot-status-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
    .bot-status-value { font-size: 15px; font-weight: 700; }
    .bot-status-value.online { color: var(--green-ok); }
    .bot-status-value.offline { color: var(--red-err); }
    .btn-outline {
      width: 100%; padding: 9px 16px; background: transparent;
      border: 1px solid var(--border); border-radius: 8px;
      font-size: 13px; font-weight: 600; font-family: inherit;
      color: var(--text); cursor: pointer; transition: all 0.15s;
    }
    .btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
    .btn-danger {
      width: 100%; padding: 9px 16px; background: transparent;
      border: 1px solid #fecaca; border-radius: 8px;
      font-size: 13px; font-weight: 600; font-family: inherit;
      color: var(--red-err); cursor: pointer; transition: all 0.15s;
    }
    .btn-danger:hover { background: #fef2f2; }
    .btn-green {
      width: 100%; padding: 9px 16px; background: var(--green-ok);
      border: none; border-radius: 8px;
      font-size: 13px; font-weight: 600; font-family: inherit;
      color: white; cursor: pointer; transition: background 0.15s;
    }
    .btn-green:hover { background: #16a34a; }

    /* ── MAIN CONTENT ────────────────────────────────────────────── */
    .main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

    /* ── CHAT AREA ───────────────────────────────────────────────── */
    #chatArea { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
    .chat-header {
      height: 64px; padding: 0 20px;
      background: var(--card-bg); border-bottom: 1px solid var(--border);
      display: flex; align-items: center; gap: 12px; flex-shrink: 0;
    }
    .chat-avatar {
      width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
      background: linear-gradient(135deg, var(--primary), var(--primary-hover));
      color: white; display: flex; align-items: center; justify-content: center;
      font-size: 15px; font-weight: 700;
    }
    .chat-header-info { flex: 1; min-width: 0; }
    .chat-header-name { font-size: 14px; font-weight: 700; color: var(--text); }
    .chat-header-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
    .chat-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
    .badge-online { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
    .badge-online::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green-ok); }
    .badge-offline::before { background: var(--red-err); }

    .messages {
      flex: 1; overflow-y: auto; padding: 20px;
      display: flex; flex-direction: column; gap: 8px;
      background: var(--main-bg);
    }
    .empty { text-align: center; color: var(--text-muted); margin: auto; font-size: 14px; }
    .empty-icon { font-size: 48px; margin-bottom: 12px; }

    /* Bubbles */
    .bubble {
      max-width: 68%; padding: 10px 14px; border-radius: 16px;
      font-size: 13.5px; line-height: 1.5; position: relative;
      box-shadow: var(--shadow);
    }
    .bubble.received {
      background: var(--bubble-in); color: var(--text);
      border-radius: 4px 16px 16px 16px; align-self: flex-start;
    }
    .bubble.sent {
      background: var(--bubble-out); color: var(--bubble-out-txt);
      border-radius: 16px 4px 16px 16px; align-self: flex-end;
    }
    .bubble .time { font-size: 10px; opacity: 0.65; margin-top: 4px; text-align: right; }

    .bubble-audio {
      display: flex; align-items: center; gap: 10px; padding: 10px 14px;
      border-radius: 16px; align-self: flex-start; max-width: 300px;
      background: var(--bubble-in); box-shadow: var(--shadow);
    }
    .bubble-audio.sent { background: var(--bubble-out); align-self: flex-end; border-radius: 16px 4px 16px 16px; }
    .bubble-audio.sent .audio-label, .bubble-audio.sent .audio-transcript, .bubble-audio.sent .audio-time { color: rgba(255,255,255,0.85) !important; }
    .audio-icon { font-size: 22px; flex-shrink: 0; }
    .audio-info { flex: 1; min-width: 0; }
    .audio-label { font-size: 12px; font-weight: 700; color: var(--text); }
    .audio-transcript { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .audio-time { font-size: 10px; color: var(--text-xs); margin-top: 3px; text-align: right; }

    .bubble-image {
      align-self: flex-start; max-width: 260px; background: var(--bubble-in);
      border-radius: 4px 16px 16px 16px; overflow: hidden; box-shadow: var(--shadow);
    }
    .bubble-image.sent { align-self: flex-end; background: var(--bubble-out); border-radius: 16px 4px 16px 16px; }
    .image-placeholder {
      background: linear-gradient(135deg, var(--primary-light), #dbeafe);
      height: 130px; display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 5px; color: var(--primary);
    }
    .image-placeholder span { font-size: 30px; }
    .image-placeholder small { font-size: 11px; font-weight: 600; }
    .image-caption { padding: 7px 12px; font-size: 12px; color: var(--text-muted); }
    .image-time { font-size: 10px; color: var(--text-xs); text-align: right; padding: 0 12px 7px; }

    .input-area {
      display: flex; gap: 10px; padding: 12px 16px;
      background: var(--card-bg); border-top: 1px solid var(--border); flex-shrink: 0;
    }
    .input-area input {
      flex: 1; padding: 10px 16px; border: 1px solid var(--border);
      border-radius: 24px; font-size: 13px; outline: none;
      font-family: inherit; transition: border-color 0.15s;
      background: var(--main-bg); color: var(--text);
    }
    .input-area input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
    .send-btn {
      background: var(--primary); color: white; border: none;
      padding: 10px 20px; border-radius: 24px; cursor: pointer;
      font-size: 13px; font-weight: 600; font-family: inherit; transition: background 0.15s;
    }
    .send-btn:hover { background: var(--primary-hover); }
    .chat-hdr-btn {
      display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px;
      background: var(--main-bg); border: 1px solid var(--border); border-radius: 8px;
      font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
      font-family: inherit; transition: all 0.15s;
    }
    .chat-hdr-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

    /* ── CONTACT RIGHT PANEL ─────────────────────────────────────── */
    .contact-panel {
      width: 0; flex-shrink: 0; background: #fff; border-left: 2px solid #dce4ef;
      display: flex; flex-direction: column; overflow: hidden;
      transition: width 0.22s ease; box-shadow: -3px 0 10px rgba(0,0,0,0.06);
    }
    .contact-panel.open { width: 280px; }
    .cp-header { padding: 20px 16px 14px; background: linear-gradient(135deg,#f8fafc,#edf1f9); border-bottom: 1px solid #dce4ef; text-align: center; flex-shrink: 0; position: relative; }
    .cp-avatar { width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: #fff; }
    .cp-name { font-size: 14px; font-weight: 700; color: var(--text); }
    .cp-phone { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
    .cp-badge { display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; background: #ede9fe; color: #7c3aed; }
    .cp-badge.human { background: #ccfbf1; color: #0f766e; }
    .cp-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
    .cp-section { background: var(--main-bg); border-radius: 10px; padding: 10px 12px; }
    .cp-section-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
    .cp-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 3px 0; }
    .cp-key { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
    .cp-val { font-size: 11px; color: var(--text); font-weight: 500; text-align: right; }
    .cp-select { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; font-family: inherit; outline: none; background: #fff; color: var(--text); }
    .cp-select:focus { border-color: var(--primary); }
    .cp-textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; font-family: inherit; outline: none; resize: vertical; min-height: 60px; color: var(--text); }
    .cp-textarea:focus { border-color: var(--primary); }
    .cp-note { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font-size: 11px; color: var(--text); }
    .cp-note-time { font-size: 10px; color: var(--text-xs); margin-top: 3px; }
    .cp-activity-item { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f1f5f9; font-size: 11px; color: var(--text-muted); }
    .cp-activity-item:last-child { border-bottom: none; }

    /* ── CONFIG SECTIONS (usadas nas sub-abas de instância) ──────── */
    .config-panel { display: none; flex-direction: column; gap: 16px; }
    .config-panel.active { display: flex; }

    .config-section {
      background: var(--card-bg); border-radius: 12px;
      border: 1px solid var(--border); overflow: hidden;
    }
    .config-section-header {
      padding: 14px 18px; border-bottom: 1px solid var(--border);
    }
    .config-section-header h3 { font-size: 13px; font-weight: 700; color: var(--text); }
    .config-section-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }

    .config-row { display: flex; flex-direction: column; gap: 6px; }
    .config-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
    .config-input {
      width: 100%; padding: 9px 13px; border: 1px solid var(--border);
      border-radius: 8px; font-size: 13px; font-family: inherit;
      outline: none; transition: border-color 0.15s; color: var(--text); background: var(--card-bg);
    }
    .config-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
    textarea.config-input { min-height: 90px; resize: vertical; line-height: 1.6; }
    .config-select {
      width: 100%; padding: 9px 13px; border: 1px solid var(--border);
      border-radius: 8px; font-size: 13px; font-family: inherit;
      outline: none; background: var(--card-bg); cursor: pointer; color: var(--text);
      transition: border-color 0.15s;
    }
    .config-select:focus { border-color: var(--primary); }
    .config-hint { font-size: 11px; color: var(--text-muted); }

    /* Toggles */
    .toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f8fafc; }
    .toggle-row:last-child { border-bottom: none; }
    .toggle-info .toggle-name { font-size: 13px; font-weight: 600; }
    .toggle-info .toggle-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
    .toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
    .toggle input { opacity: 0; width: 0; height: 0; }
    .toggle-slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 24px; cursor: pointer; transition: 0.25s; }
    .toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: 0.25s; }
    .toggle input:checked + .toggle-slider { background: var(--primary); }
    .toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

    /* Voice list */
    .voice-list { display: flex; flex-direction: column; gap: 6px; }
    .voice-item {
      display: flex; align-items: center; gap: 10px; padding: 10px 12px;
      border: 2px solid var(--border); border-radius: 10px; cursor: pointer; transition: all 0.15s;
    }
    .voice-item:hover { border-color: var(--primary); background: var(--primary-light); }
    .voice-item.selected { border-color: var(--primary); background: var(--primary-light); }
    .voice-item-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex-shrink: 0; transition: background 0.15s; }
    .voice-item.selected .voice-item-dot { background: var(--primary); }
    .voice-item-info { flex: 1; }
    .voice-item-name { font-size: 13px; font-weight: 600; }
    .voice-item-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
    .voice-item-tag { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--primary-light); color: var(--primary); }

    /* Schedule inputs */
    .horario-day { margin-bottom: 12px; }
    .horario-day:last-child { margin-bottom: 0; }
    .horario-day-label { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
    .horario-times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .horario-time-group { display: flex; flex-direction: column; gap: 4px; }
    .horario-time-label { font-size: 10px; color: var(--text-muted); font-weight: 500; }

    /* Range sliders */
    .range-row { display: flex; align-items: center; gap: 10px; }
    .range-value {
      min-width: 44px; text-align: center; font-size: 13px; font-weight: 700;
      color: var(--primary); background: var(--primary-light); padding: 4px 8px; border-radius: 8px;
    }
    input[type=range] { flex: 1; accent-color: var(--primary); height: 4px; cursor: pointer; }

    /* Info box */
    .info-box { background: var(--primary-light); border: 1px solid #bfdbfe; border-radius: 8px; padding: 10px 12px; font-size: 12px; color: #1d4ed8; display: flex; gap: 8px; align-items: flex-start; }
    .info-box-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

    .connected-badge { display: inline-flex; align-items: center; gap: 6px; background: #dcfce7; color: #166534; border-radius: 20px; padding: 6px 14px; font-size: 13px; font-weight: 600; margin-bottom: 16px; }
    .connected-badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--green-ok); }

    /* ── PATIENT PAGE ────────────────────────────────────────────── */
    #patientPage {
      flex: 1; display: none; align-items: center; justify-content: center;
      background: var(--main-bg);
    }
    #patientPage.active { display: flex; }
    .patient-empty-main { text-align: center; color: var(--text-muted); }
    .patient-empty-main-icon { font-size: 56px; margin-bottom: 12px; }
    .patient-empty-main h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }

    /* ── TOAST ───────────────────────────────────────────────────── */
    #toastContainer { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column-reverse; gap: 8px; }
    .toast {
      display: flex; align-items: center; gap: 10px;
      background: var(--card-bg); border: 1px solid var(--border);
      border-radius: 12px; padding: 12px 14px; min-width: 280px; max-width: 360px;
      box-shadow: var(--shadow-md); cursor: pointer; animation: slideIn 0.2s ease;
    }
    @keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
    .toast.fadeOut { opacity: 0; transition: opacity 0.3s; }
    .toast-icon { font-size: 20px; flex-shrink: 0; }
    .toast-name { font-size: 13px; font-weight: 700; color: var(--text); }
    .toast-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
    .toast-close { border: none; background: transparent; color: var(--text-muted); cursor: pointer; padding: 2px; font-size: 14px; }

    /* ── PATIENTS TOOLBAR ────────────────────────────────────────── */
    #patientsToolbar {
      display: none; align-items: center; gap: 8px; padding: 10px 12px;
      border-bottom: 1px solid var(--border); flex-shrink: 0;
    }
    .btn-sm {
      padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
      font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
      background: var(--card-bg); color: var(--text); transition: all 0.15s;
    }
    .btn-sm:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
    #patientCount { font-size: 11px; color: var(--text-muted); margin-left: auto; }

    /* Scrollbars */
    ::-webkit-scrollbar { width: 4px; height: 4px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

    /* ── BOT TOGGLE POR CONVERSA (Feature 1) ─────────────────────── */
    .bot-conv-toggle {
      display: flex; align-items: center; gap: 5px; padding: 5px 11px;
      border-radius: 8px; border: 1.5px solid; font-size: 11px; font-weight: 700;
      font-family: inherit; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
    }
    .bot-conv-toggle.active  { background: #dcfce7; border-color: #22c55e; color: #166534; }
    .bot-conv-toggle.paused  { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
    .bot-conv-toggle svg { width: 13px; height: 13px; }

    /* ── DASHBOARD ──────────────────────────────────────────────────── */
    .dash-page { flex: 1; display: none; overflow-y: auto; background: #f8fafc; flex-direction: column; }
    .dash-page.active { display: flex; }
    .dash-header { padding: 20px 28px 0; }
    .dash-header h1 { font-size: 20px; font-weight: 700; color: var(--text); }
    .dash-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
    .dash-body { padding: 20px 28px; display: flex; flex-direction: column; gap: 20px; flex: 1; }

    /* KPI cards */
    .dash-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
    .kpi-card {
      background: #fff; border-radius: 14px; padding: 18px 20px;
      border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,0.05);
      display: flex; flex-direction: column; gap: 8px;
    }
    .kpi-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
    .kpi-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
    .kpi-sub { font-size: 12px; color: var(--text-muted); }
    .kpi-icon { font-size: 22px; margin-bottom: 2px; }
    .kpi-card.kpi-blue .kpi-value { color: #3b82f6; }
    .kpi-card.kpi-green .kpi-value { color: #22c55e; }
    .kpi-card.kpi-purple .kpi-value { color: #8b5cf6; }
    .kpi-card.kpi-amber .kpi-value { color: #f59e0b; }

    /* Charts row */
    .dash-charts { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
    .dash-chart-card {
      background: #fff; border-radius: 14px; padding: 18px 20px;
      border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,0.05);
      display: flex; flex-direction: column;
    }
    .dash-chart-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 14px; flex-shrink: 0; }
    .dash-chart-wrap { position: relative; height: 210px; width: 100%; flex-shrink: 0; }
    .dash-chart-empty { height: 210px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-muted); flex-direction: column; gap: 8px; }
    .dash-chart-empty span { font-size: 28px; opacity: 0.4; }

    /* Bottom row */
    .dash-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
    .dash-section {
      background: #fff; border-radius: 14px; padding: 18px 20px;
      border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,0.05);
      display: flex; flex-direction: column; gap: 10px;
    }
    .dash-section-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
    .dash-activity-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f1f5f9; }
    .dash-activity-item:last-child { border-bottom: none; }
    .dash-act-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; }
    .dash-act-info { flex: 1; min-width: 0; }
    .dash-act-name { font-size: 12px; font-weight: 600; color: var(--text); }
    .dash-act-preview { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .dash-act-time { font-size: 10px; color: var(--text-xs); white-space: nowrap; flex-shrink: 0; }
    .dash-no-resp-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
    .dash-no-resp-item:last-child { border-bottom: none; }
    .dash-no-resp-name { font-size: 12px; font-weight: 600; color: var(--text); flex: 1; }
    .dash-no-resp-time { font-size: 11px; color: #ef4444; font-weight: 600; }
    .dash-empty { padding: 16px; text-align: center; font-size: 12px; color: var(--text-muted); }

    /* Dashboard: loading / refresh / instance badge */
    .dash-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
    .dash-inst-badge {
      display: inline-flex; align-items: center; gap: 5px;
      background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
      border-radius: 20px; padding: 2px 10px; font-size: 11px; font-weight: 600;
      vertical-align: middle; margin-left: 8px;
    }
    .dash-refresh-btn {
      background: none; border: 1px solid var(--border); border-radius: 8px;
      padding: 6px 12px; font-size: 12px; font-weight: 500; color: var(--text-muted);
      cursor: pointer; display: flex; align-items: center; gap: 5px; flex-shrink: 0;
      transition: all 0.15s; font-family: inherit;
    }
    .dash-refresh-btn:hover { background: #f1f5f9; color: var(--text); border-color: #94a3b8; }
    .dash-refresh-btn.loading { pointer-events: none; opacity: 0.6; }
    .dash-refresh-btn.loading svg { animation: dashSpin 0.8s linear infinite; }
    @keyframes dashSpin { to { transform: rotate(360deg); } }
    .kpi-value.kpi-loading { color: #e2e8f0 !important; animation: kpiPulse 1.1s ease-in-out infinite; }
    @keyframes kpiPulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

    /* ── CRM Redesign ─────────────────────────────────────────────── */
    .crm-page { flex: 1; display: none; overflow: hidden; flex-direction: column; background: #f8fafc; }
    .crm-page.active { display: flex; }

    /* Board header */
    .crm-board-header {
      padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--border);
      display: flex; align-items: center; gap: 12px; flex-shrink: 0;
    }
    .crm-board-title { font-size: 15px; font-weight: 700; color: var(--text); }
    .crm-board-meta { display: flex; gap: 14px; margin-left: auto; align-items: center; }
    .crm-board-chip {
      font-size: 12px; color: var(--text-muted);
      background: var(--main-bg); border: 1px solid var(--border);
      padding: 4px 10px; border-radius: 20px;
    }
    .crm-board-chip strong { color: var(--text); }

    /* Kanban body wrapper */
    .crm-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }
    .crm-kanban { flex: 1; overflow-x: auto; display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; }

    /* Columns */
    .crm-col {
      min-width: 260px; width: 260px; flex-shrink: 0;
      background: #fff; border-radius: 14px; border: 1px solid var(--border);
      display: flex; flex-direction: column; max-height: calc(100vh - 130px);
      box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    }
    .crm-col-header {
      padding: 12px 14px; border-bottom: 1px solid var(--border);
      display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    }
    .crm-col-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
    .crm-col-label { font-size: 12px; font-weight: 700; flex: 1; color: var(--text); }
    .crm-col-count { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
    .crm-col-sum { font-size: 10px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }

    .crm-cards { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; transition: background 0.15s; }
    .crm-cards.drag-over { background: var(--primary-light); border-radius: 8px; }

    /* Empty state */
    .crm-col-empty { padding: 28px 12px; text-align: center; color: var(--text-muted); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
    .crm-col-empty-icon { font-size: 30px; opacity: 0.45; }

    /* Add card button */
    .crm-col-add {
      margin: 6px 8px 8px; padding: 8px 12px;
      border: 1.5px dashed var(--border); border-radius: 10px;
      text-align: center; font-size: 12px; font-weight: 600; color: var(--text-muted);
      cursor: pointer; transition: all 0.15s; flex-shrink: 0; user-select: none;
    }
    .crm-col-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

    /* Cards */
    .crm-card {
      background: #fff; border: 1px solid var(--border); border-radius: 12px;
      padding: 11px 12px; cursor: pointer; transition: all 0.15s;
      box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .crm-card:hover { box-shadow: var(--shadow-md); border-color: #c7d2e0; transform: translateY(-1px); }
    .crm-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-ring); }
    .crm-card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
    .crm-card-avatar {
      width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
      display: flex; align-items: center; justify-content: center;
      font-size: 14px; font-weight: 700; color: #fff;
    }
    .crm-card-info { flex: 1; min-width: 0; }
    .crm-card-name { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .crm-card-phone { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
    .crm-card-score { font-size: 12px; font-weight: 700; color: var(--primary); background: var(--primary-light); padding: 3px 8px; border-radius: 20px; flex-shrink: 0; }
    .crm-card-preview { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; }
    .crm-card-footer { display: flex; align-items: center; gap: 5px; }
    .urgency-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
    .u-high   { background: #fee2e2; color: #991b1b; }
    .u-medium { background: #fef3c7; color: #92400e; }
    .u-low    { background: #dcfce7; color: #166534; }
    .crm-card-action { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 5px; border-radius: 6px; opacity: 0.55; transition: opacity 0.15s, background 0.15s; }
    .crm-card-action:hover { opacity: 1; background: var(--main-bg); }

    /* CRM Pick Contact Modal */
    #crmPickContactModal {
      display: none; position: fixed; inset: 0; z-index: 1000;
      background: rgba(0,0,0,0.35); align-items: center; justify-content: center;
    }
    .crm-pick-box {
      background: #fff; border-radius: 16px; width: 420px; max-width: 94vw;
      box-shadow: 0 20px 60px rgba(0,0,0,0.2); display: flex; flex-direction: column; overflow: hidden;
    }
    .crm-pick-hdr {
      padding: 16px 18px 12px; border-bottom: 1px solid var(--border);
      display: flex; align-items: center; justify-content: space-between;
    }
    .crm-pick-hdr h3 { font-size: 14px; font-weight: 700; margin: 0; }
    .crm-pick-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
    .crm-pick-search-wrap { padding: 10px 14px; border-bottom: 1px solid var(--border); }
    .crm-pick-search-wrap input {
      width: 100%; padding: 9px 12px; border: 1px solid #c9d4e4; border-radius: 10px;
      font-size: 13px; font-family: inherit; outline: none; color: var(--text);
    }
    .crm-pick-search-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
    .crm-pick-list { max-height: 340px; overflow-y: auto; padding: 6px; }
    .crm-pick-item {
      display: flex; align-items: center; gap: 10px; padding: 9px 10px;
      border-radius: 10px; cursor: pointer; transition: background 0.12s;
    }
    .crm-pick-item:hover { background: #f0f4fb; }
    .crm-pick-avatar {
      width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
      display: flex; align-items: center; justify-content: center;
      font-size: 14px; font-weight: 700; color: #fff;
    }
    .crm-pick-info { flex: 1; min-width: 0; }
    .crm-pick-name { font-size: 13px; font-weight: 600; color: var(--text); }
    .crm-pick-phone { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
    .crm-pick-empty { padding: 24px; text-align: center; font-size: 13px; color: var(--text-muted); }

    /* CRM Detail Panel */
    .crm-detail { width: 320px; flex-shrink: 0; background: var(--card-bg); border-left: 1px solid var(--border); display: none; flex-direction: column; overflow: hidden; }
    .crm-detail.open { display: flex; }
    .crm-detail-hdr { height: 64px; padding: 0 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
    .crm-detail-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg,#8b5cf6,#6d28d9); color: white; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
    .crm-detail-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
    .crm-field { display: flex; flex-direction: column; gap: 4px; }
    .crm-field label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
    .crm-sel, .crm-txt {
      width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
      font-size: 12px; font-family: inherit; outline: none; color: var(--text); background: var(--main-bg);
    }
    .crm-sel:focus, .crm-txt:focus { border-color: var(--primary); }
    .crm-txt { min-height: 70px; resize: vertical; }
    .crm-score-row { display: flex; align-items: center; gap: 8px; }
    .crm-score-val { min-width: 34px; text-align: center; font-size: 12px; font-weight: 700; color: var(--primary); background: var(--primary-light); padding: 3px 6px; border-radius: 6px; }
    .act-list { display: flex; flex-direction: column; gap: 6px; }
    .act-item { display: flex; gap: 8px; padding: 7px 9px; background: var(--main-bg); border-radius: 8px; }
    .act-icon { font-size: 13px; flex-shrink: 0; }
    .act-desc { flex: 1; font-size: 11px; color: var(--text); line-height: 1.4; }
    .act-time { font-size: 10px; color: var(--text-xs); white-space: nowrap; }
    .crm-note-row { display: flex; gap: 6px; }
    .crm-note-row input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; font-family: inherit; outline: none; }
    .crm-note-row input:focus { border-color: var(--primary); }
    .btn-crm-save { width: 100%; padding: 8px; background: var(--primary); color: white; border: none; border-radius: 8px; font-size: 12px; font-weight: 700; font-family: inherit; cursor: pointer; }
    .btn-crm-save:hover { background: var(--primary-hover); }
    /* CRM Sidebar */
    .crm-sidebar-filters { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
    .crm-filter-btn { width: 100%; text-align: left; padding: 9px 12px; border: none; background: transparent; border-radius: 8px; font-size: 13px; font-family: inherit; color: var(--text); cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 8px; font-weight: 500; }
    .crm-filter-btn:hover { background: #e8eef8; color: var(--text); }
    .crm-filter-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 700; border-left: 3px solid var(--primary); }
    .crm-filter-count { margin-left: auto; font-size: 11px; font-weight: 700; background: rgba(0,0,0,0.07); padding: 1px 7px; border-radius: 20px; }

    /* ── NÚMEROS / INSTÂNCIAS (Feature 2) ────────────────────────── */
    .numbers-page { flex: 1; min-height: 0; display: none; overflow: hidden; background: var(--main-bg); }
    .numbers-page.active { display: flex; flex-direction: column; }

    /* Admin: mesma estrutura de inst-detail/inst-tab-content da página Numbers */
    #adminDetail { flex: 1; display: none; flex-direction: column; overflow: hidden; }
    #adminUserForm { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
    #adminUserForm > * { flex-shrink: 0; }
    /* Empty state */
    .inst-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-muted); padding: 40px; }
    .inst-empty-icon { font-size: 52px; }
    .inst-empty h3 { font-size: 15px; font-weight: 600; color: var(--text); }
    .inst-empty p { font-size: 13px; }
    /* Instance detail panel */
    .inst-detail { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
    .inst-detail-hdr { height: 64px; padding: 0 20px; background: var(--card-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
    .inst-detail-badge { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
    .inst-detail-info { flex: 1; min-width: 0; }
    .inst-detail-name { font-size: 14px; font-weight: 700; }
    .inst-detail-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
    .inst-detail-actions { display: flex; gap: 6px; flex-shrink: 0; }
    .inst-detail-btn { padding: 6px 13px; border-radius: 7px; font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); transition: all 0.15s; white-space: nowrap; }
    .inst-detail-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
    .inst-detail-btn.green { background: var(--green-ok); border-color: var(--green-ok); color: white; }
    .inst-detail-btn.green:hover { background: #16a34a; border-color: #16a34a; }
    .inst-detail-btn.red { border-color: #fecaca; color: var(--red-err); }
    .inst-detail-btn.red:hover { background: #fef2f2; }
    /* Instance sub-tabs */
    .inst-tabs { display: flex; gap: 2px; padding: 8px 20px; background: var(--card-bg); border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; }
    .inst-tab-btn { padding: 7px 14px; border: none; background: transparent; border-radius: 8px; font-size: 12px; font-weight: 600; font-family: inherit; color: var(--text-muted); cursor: pointer; transition: all 0.15s; white-space: nowrap; }
    .inst-tab-btn:hover { background: var(--main-bg); color: var(--text); }
    .inst-tab-btn.active { background: var(--primary-light); color: var(--primary); }
    .inst-tab-content { flex: 1; overflow-y: auto; padding: 20px; }
    .inst-panel { display: none; flex-direction: column; gap: 16px; }
    .inst-panel.active { display: flex; }
    /* Conexão panel */
    .inst-conexao-wrap { display: flex; justify-content: center; }
    .inst-conexao-card { background: var(--card-bg); border-radius: 16px; border: 1px solid var(--border); padding: 28px; text-align: center; max-width: 380px; width: 100%; box-shadow: var(--shadow-md); }
    .inst-conexao-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
    .inst-conexao-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }
    .inst-qr-large { width: 220px; height: 220px; border-radius: 12px; margin: 0 auto 16px; display: block; object-fit: contain; }
    .inst-qr-ph-large { width: 220px; height: 220px; border-radius: 12px; margin: 0 auto 16px; background: var(--main-bg); border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text-muted); }
    .inst-conexao-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
    /* Instance save bar */
    .inst-save-bar { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--card-bg); flex-shrink: 0; display: flex; align-items: center; gap: 12px; }
    /* Numbers sidebar */
    .inst-sidebar-list { flex: 1; overflow-y: auto; }
    .inst-sidebar-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid #dce4ef; transition: background 0.1s; }
    .inst-sidebar-item:hover { background: #e8eef8; }
    .inst-sidebar-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }

    /* ── Cards de Anexos ── */
    .anexo-card { display:flex; align-items:flex-start; gap:12px; padding:12px 14px; background:var(--surface); border:1.5px solid var(--border); border-radius:10px; }
    .anexo-icon-pdf { width:48px; height:48px; background:#fee2e2; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:24px; flex-shrink:0; }
    .anexo-icon-img { width:48px; height:48px; border-radius:8px; object-fit:cover; flex-shrink:0; border:1.5px solid var(--border); }
    .anexo-info { flex:1; display:flex; flex-direction:column; gap:4px; min-width:0; }
    .anexo-filename { font-size:13px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .anexo-instrucao { font-size:12px; color:var(--text-muted); line-height:1.45; white-space:pre-wrap; word-break:break-word; }
    .anexo-del-btn { width:28px; height:28px; border-radius:50%; background:rgba(0,0,0,0.08); color:var(--text-muted); border:none; cursor:pointer; font-size:17px; display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:all 0.15s; margin-top:2px; }
    .anexo-del-btn:hover { background:#ef4444; color:#fff; }
    .anexo-pendente-box { border:1.5px dashed var(--accent); border-radius:10px; padding:14px; display:flex; flex-direction:column; gap:10px; background:var(--primary-light); }
    .anexo-add-btn { display:inline-flex; align-items:center; gap:7px; padding:8px 16px; border:1.5px solid var(--border); border-radius:8px; font-size:13px; font-weight:500; cursor:pointer; background:var(--surface); color:var(--text-muted); transition:all 0.15s; }
    .anexo-add-btn:hover:not(:disabled) { border-color:var(--accent); color:var(--accent); }
    .anexo-add-btn:disabled { opacity:0.5; cursor:not-allowed; }
    .anexo-uploading { display:inline-flex; align-items:center; gap:7px; font-size:13px; color:var(--accent); padding:8px 0; }
    .anexo-erro { font-size:12px; color:#ef4444; padding:6px 10px; background:#fef2f2; border-radius:6px; border:1px solid #fecaca; }

    /* ── Barra seletora de instância (Conversas / CRM) ── */
    .inst-filter-bar { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; flex-shrink: 0; border-bottom: 1px solid #dce4ef; background: #edf1f9; scrollbar-width: none; }
    .inst-filter-bar::-webkit-scrollbar { display: none; }
    .inst-filter-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 500; cursor: pointer; white-space: nowrap; border: 1.5px solid var(--border); background: transparent; color: var(--text-muted); transition: all 0.15s; }
    .inst-filter-pill:hover { border-color: var(--accent); color: var(--accent); }
    .inst-filter-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
    .inst-filter-pill .fdot { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; flex-shrink: 0; }
    .inst-filter-pill .fdot.online { background: #22c55e; }
    .inst-sidebar-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
    .inst-sidebar-name { font-size: 13px; font-weight: 600; }
    .inst-sidebar-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

    /* ── Admin: painel de estatísticas de instância ── */
    .admin-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
    .admin-stat-card { background: var(--main-bg); border-radius: 10px; padding: 12px; text-align: center; }
    .admin-stat-num { font-size: 22px; font-weight: 700; }
    .admin-stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
    .admin-stage-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
    .admin-stage-pill { border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 600; }
    .admin-contact-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
    .admin-contact-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: white; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
    .admin-contact-info { flex: 1; min-width: 0; }
    .admin-contact-name { font-size: 12px; font-weight: 600; color: var(--text); }
    .admin-contact-msg { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .admin-view-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary); border-radius: 7px; font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
    .admin-view-btn:hover { background: var(--primary); color: white; }

    /* CRM: botão mover (só visível no mobile) */
    .crm-card-move-btn {
      display: none;
      align-items: center; gap: 4px;
      padding: 4px 10px; border-radius: 20px;
      border: 1px solid var(--border); background: var(--main-bg);
      font-size: 11px; font-weight: 600; color: var(--text-muted);
      cursor: pointer; font-family: inherit; transition: all 0.15s;
    }
    .crm-card-move-btn:hover { border-color: var(--primary); color: var(--primary); }
    .crm-move-option {
      width: 100%; padding: 14px 16px; border: 1px solid var(--border);
      border-radius: 10px; background: #fff; text-align: left;
      font-size: 14px; font-weight: 600; font-family: inherit;
      cursor: pointer; color: var(--text); transition: background 0.15s;
    }
    .crm-move-option:hover { background: var(--main-bg); }

    /* Dropdown de ações do chat (mobile) */
    #chatMoreBtn { display: none; background: none; border: none; cursor: pointer; padding: 4px 8px; color: var(--text-muted); align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; line-height: 1; }
    #chatDropdown {
      flex-direction: column; flex-shrink: 0;
      background: var(--card-bg); border-bottom: 2px solid var(--border);
      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }
    .chat-dropdown-item {
      display: flex; align-items: center; gap: 12px;
      width: 100%; padding: 13px 20px; border: none; background: none;
      font-size: 13px; font-weight: 600; font-family: inherit; color: var(--text);
      cursor: pointer; text-align: left; transition: background 0.15s;
      border-bottom: 1px solid var(--border);
    }
    .chat-dropdown-item:last-child { border-bottom: none; }
    .chat-dropdown-item:hover { background: var(--main-bg); }
    .chat-dropdown-item svg { color: var(--primary); flex-shrink: 0; }

    /* ── MOBILE RESPONSIVE ──────────────────────────────────────── */
    #mobileBackBtn { display: none; }

    @media (max-width: 768px) {
      /* Nav rail → bottom tab bar */
      .nav-rail {
        position: fixed;
        bottom: 0; left: 0; right: 0; top: auto;
        width: 100%;
        height: 56px;
        flex-direction: row;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding: 0;
        z-index: 300;
      }
      .nav-brand { display: none; }
      .nav-items { flex-direction: row; justify-content: space-around; padding: 0; flex: 1; width: auto; }
      .nav-bottom { flex-direction: row; padding: 0 12px; gap: 8px; align-items: center; }
      .status-dot { width: 8px; height: 8px; }

      /* App layout */
      .app { flex-direction: column; }

      /* Sidebar → full screen, fixed */
      .sidebar {
        position: fixed !important;
        top: 0; left: 0; right: 0; bottom: 56px;
        width: 100% !important;
        z-index: 200;
        transform: translateX(0);
        transition: transform 0.25s ease;
      }
      /* Hide sidebar when chat is open */
      body.mobile-chat-open .sidebar {
        transform: translateX(-100%);
        pointer-events: none;
      }

      /* Main → full screen, fixed */
      .main {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 56px;
        width: 100%;
        z-index: 100;
      }

      /* Contact panel → full screen overlay */
      .contact-panel.open {
        position: fixed;
        top: 0; right: 0; bottom: 56px;
        width: 100% !important;
        z-index: 250;
      }

      /* Back button visible on mobile */
      #mobileBackBtn { display: flex !important; }

      /* Toast above bottom nav */
      #toastContainer { bottom: 66px; right: 12px; left: 12px; max-width: 100%; }
      .toast { min-width: 0; max-width: 100%; }

      /* Dashboard */
      .dash-kpis { grid-template-columns: repeat(2, 1fr); }
      .dash-charts { grid-template-columns: 1fr; }
      .dash-bottom { grid-template-columns: 1fr; }
      .dash-header { padding: 16px 16px 0; }
      .dash-body { padding: 16px; gap: 14px; }

      /* CRM board header simplified */
      .crm-board-meta { display: none; }
      .crm-col { min-width: 240px; width: 240px; }

      /* Chat header: esconde botões individuais, mostra "⋯" */
      #btnVerLead, #botConvToggle, #btnContactPanel { display: none !important; }
      #chatMoreBtn { display: flex !important; }

      /* Painel de contato: botão X só visível quando painel estiver aberto */
      .contact-panel.open #cpMobileClose { display: flex !important; }

      /* Numbers/Admin pages */
      .numbers-page { padding-bottom: 0; }

      /* CRM: mostra botão mover nos cards */
      .crm-card-move-btn { display: inline-flex !important; }

      /* CRM e Tags: sidebar escondida, conteúdo principal ocupa tudo */
      body.mobile-tab-crm .sidebar,
      body.mobile-tab-tags .sidebar { display: none !important; }

      /* CRM detail panel: tela cheia */
      body.mobile-tab-crm .crm-detail.open {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 56px;
        width: 100% !important;
        z-index: 250;
      }

      /* Botões voltar de Números e Admin visíveis no mobile */
      #mobileBackNumbers, #mobileBackAdmin { display: flex !important; }
    }
