/* ============= WIC MONITOR — Design System v2 ============= */
:root {
  --bg-app: #0a0e14;
  --bg-sidebar: #0d1117;
  --bg-content: #0f1923;
  --bg-card: #151f2b;
  --bg-card-hover: #1a2736;
  --bg-input: #0d1117;
  --bg-chat-area: #0a0e14;
  --accent: #00a884;
  --accent-glow: rgba(0,168,132,0.2);
  --accent-dark: #008a6e;
  --accent-insta: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  --accent-fb: #1877F2;
  --accent-fb-dark: #0d5fcc;
  --accent-fb-glow: rgba(24,119,242,0.2);
  --green: #22c55e;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --red: #ef4444;
  --text-1: #e6edf3;
  --text-2: #8b949e;
  --text-3: #484f58;
  --border: rgba(139,148,158,0.12);
  --radius: 10px;
  --radius-lg: 14px;
  --font: 'Inter', -apple-system, sans-serif;
  --tr: 0.2s ease;
}
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg-app); color: var(--text-1); height: 100vh; overflow: hidden; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-3); border-radius: 3px; }

.login-card {
  position: relative; z-index: 1;
  background: rgba(15,25,35,0.9); backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 44px 36px; width: 400px; max-width: 90vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  animation: cardIn .4s ease-out;
}
@keyframes cardIn { from{opacity:0;transform:translateY(16px) scale(.97)} to{opacity:1;transform:none} }

.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon {
  width: 64px; height: 64px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #fff; box-shadow: 0 0 30px var(--accent-glow);
}
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-subtitle { color: var(--text-2); font-size: 13px; margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.input-group { display: flex; flex-direction: column; gap: 5px; }
.input-group label { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; }
.input-group input {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 14px; color: var(--text-1); font-family: var(--font); font-size: 14px;
  outline: none; transition: var(--tr);
}
.input-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-group input::placeholder { color: var(--text-3); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none; border-radius: 8px; padding: 12px; color: #fff;
  font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: var(--tr); margin-top: 4px;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-secondary { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 10px 18px; color: var(--text-2); font-family: var(--font); font-size: 13px; cursor: pointer; transition: var(--tr); }
.btn-secondary:hover { border-color: var(--text-2); color: var(--text-1); }

.btn-accent { background: var(--accent); border: none; border-radius: 8px; padding: 9px 18px; color: #fff; font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: var(--tr); }
.btn-accent:hover { background: var(--accent-dark); }

.btn-danger { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3); border-radius: 8px; padding: 10px 18px; color: var(--red); font-family: var(--font); font-size: 13px; cursor: pointer; transition: var(--tr); display: flex; align-items: center; gap: 6px; margin-top: 16px; }
.btn-danger:hover { background: rgba(239,68,68,.25); }

.btn-sm { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; color: var(--text-2); font-family: var(--font); font-size: 12px; cursor: pointer; transition: var(--tr); display: flex; align-items: center; gap: 5px; }
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm.danger:hover { border-color: var(--red); color: var(--red); }

.error-msg {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: 8px;
  padding: 12px 14px;
  color: #f87171;
  font-size: 13px;
  line-height: 1.5;
}
.error-msg b { color: #fca5a5; }
.error-msg code {
  background: rgba(0,0,0,.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}
.error-msg small { opacity: 0.85; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto; }
.spinner-sm { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .5s linear infinite; display: inline-block; }
@keyframes spin { to{transform:rotate(360deg)} }
.loading { padding: 30px; text-align: center; }

/* ============= LOGIN SCREEN ============= */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, var(--bg-app), #071210, var(--bg-app));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.login-container { width: 100%; max-width: 600px; text-align: center; }
.login-roles {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px;
}
.role-card {
  background: var(--bg-sidebar); border: 2px solid var(--border); border-radius: 20px;
  padding: 30px 20px; cursor: pointer; transition: all 0.3s ease;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.role-card:hover { border-color: var(--accent); transform: translateY(-5px); background: rgba(0,168,132,0.05); }
.role-card i { font-size: 40px; color: var(--text-3); transition: color 0.3s; }
.role-card:hover i { color: var(--accent); }
.role-card h3 { margin: 0; font-size: 18px; color: var(--text-1); }
.role-card p { margin: 0; font-size: 13px; color: var(--text-3); line-height: 1.4; }

.login-form-box {
  margin-top: 30px; animation: slideUp 0.3s ease;
}
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:none} }

.login-back {
  display: inline-flex; align-items: center; gap: 6px; color: var(--text-3);
  font-size: 13px; cursor: pointer; margin-bottom: 20px;
}
.login-back:hover { color: var(--text-1); }

/* ============= APP LAYOUT ============= */
.app-layout { display: flex; flex-direction: column; height: 100vh; animation: fadeIn .3s ease; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.app-header {
  height: 56px; display: flex; align-items: center; padding: 0 16px;
  background: var(--bg-sidebar); border-bottom: 1px solid var(--border);
  gap: 0; flex-shrink: 0; overflow-x: auto;
}
.app-header::-webkit-scrollbar { height: 0; }

.header-brand {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding-right: 16px; border-right: 1px solid var(--border); margin-right: 12px;
}
.brand-name {
  font-size: 13px; font-weight: 700; color: var(--text-1);
  letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap;
}

.top-nav {
  display: flex; align-items: center; gap: 2px; flex: 1;
}

.header-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
  padding-left: 12px; border-left: 1px solid var(--border); margin-left: 12px;
}

.nav-sep {
  width: 1px; height: 24px; background: var(--border); margin: 0 6px; flex-shrink: 0;
}

.nav-section-label {
  display: flex; align-items: center; padding: 0 4px 0 2px;
  font-size: 14px; color: var(--text-3); flex-shrink: 0;
}
.nav-section-label .fa-whatsapp { color: #25d366; }
.nav-section-label .fa-instagram { color: #e6683c; }

.admin-only.hidden-role { display: none !important; }

.nav-btn {
  padding: 6px 10px; border: none; background: transparent;
  color: var(--text-3); cursor: pointer; border-radius: 8px;
  display: flex; flex-direction: row; align-items: center; gap: 6px;
  transition: var(--tr); font-family: var(--font); white-space: nowrap; flex-shrink: 0;
  position: relative;
}
.nav-btn i { font-size: 13px; transition: var(--tr); }
.nav-btn span { font-size: 12px; font-weight: 500; }
.nav-btn:hover { color: var(--text-1); background: var(--bg-card); }
.nav-btn.active { color: var(--accent); background: rgba(0,168,132,.12); }

.role-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  background: rgba(0,168,132,.1); color: var(--accent); font-size: 13px;
}

.btn-logout {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-3); cursor: pointer;
  transition: var(--tr); font-size: 14px;
}
.btn-logout:hover { background: rgba(239,68,68,.15); color: var(--red); }

/* ============= INSTAGRAM MODULE ============= */
.insta-card {
  position: relative; overflow: hidden; border-radius: 16px; 
  background: var(--bg-card); border: 1px solid var(--border);
  transition: transform 0.3s ease;
}
.insta-card:hover { transform: translateY(-5px); border-color: #e6683c; }
.insta-card-bg {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  filter: blur(5px) brightness(0.4); opacity: 0.8; z-index: 1;
}
.insta-card-content {
  position: relative; z-index: 2; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: rgba(15, 25, 35, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: 100%;
}
.insta-avatar {
  width: 80px; height: 80px; border-radius: 50%; padding: 3px;
  background: var(--accent-insta);
}
.insta-avatar img { width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--bg-card); object-fit: cover; }
.insta-handle { font-weight: 600; color: #fff; font-size: 16px; }
.insta-badge { background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 20px; font-size: 11px; color: var(--text-2); }
.module-instagram.active i { 
  background: var(--accent-insta); 
  -webkit-background-clip: text; 
  background-clip: text; 
  -webkit-text-fill-color: transparent; 
}
.nav-btn.active::after {
  content: ''; position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%);
  width: 60%; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0;
}

/* Nav Group (Accordion) & App Modules */
.nav-group {
  display: flex; flex-direction: column; width: 100%; margin-bottom: 8px;
}

.app-module-btn {
  width: 46px; height: 46px; margin: 0 auto 12px auto;
  border-radius: 12px; border: none;
  color: #fff; font-size: 22px; font-weight: 500; font-family: var(--font);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 2px;
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.app-module-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.3); }
.app-module-btn.active { box-shadow: inset 0 2px 6px rgba(0,0,0,0.4); transform: translateY(1px); }

.module-dashboard { background: linear-gradient(135deg, #ef4444, #b91c1c); } /* Rojo */
.module-whatsapp { background: linear-gradient(135deg, #10b981, #047857); } /* Verde */
.module-facebook { background: linear-gradient(135deg, #6366f1, #4338ca); } /* Morado/Azul */
.module-instagram { background: linear-gradient(135deg, #3b82f6, #1d4ed8); } /* Azul */

.nav-subgroup {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  overflow: hidden; transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 0; opacity: 0; pointer-events: none;
}
.nav-subgroup.open {
  max-height: 200px; opacity: 1; pointer-events: auto; margin-bottom: 12px;
}
.nav-subgroup .nav-btn {
  width: 48px; border-radius: 8px; padding: 10px 0;
}
.nav-subgroup .nav-btn i { font-size: 16px; }
.nav-subgroup .nav-btn span { font-size: 8.5px; }

/* Content Area */
.content-area { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.view { display: none; flex-direction: column; height: 100%; overflow-y: auto; }
.view.active { display: flex; }

.view-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 12px; flex-shrink: 0;
}
.view-header h2 { font-size: 22px; font-weight: 700; }
.view-header.compact { padding: 14px 16px 8px; }
.view-header.compact h2 { font-size: 17px; }

.view-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px 16px; gap: 16px; flex-shrink: 0;
}
.client-count { font-size: 13px; color: var(--text-2); white-space: nowrap; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; flex: 1; max-width: 360px;
}
.search-box i { color: var(--text-3); font-size: 13px; }
.search-box input { background: transparent; border: none; color: var(--text-1); font-family: var(--font); font-size: 13px; outline: none; width: 100%; }
.search-box input::placeholder { color: var(--text-3); }
.mx { margin: 0 16px 10px; max-width: none; flex: none; width: auto; }
.chats-sidebar .search-box { max-width: none; flex: none; }

/* ============= DASHBOARD SECTIONS ============= */
.dash-section { margin-bottom: 32px; }
.dash-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.dash-section-header h3 { font-size: 16px; font-weight: 600; color: var(--text-1); }
.dash-section-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.dash-section-icon.wa { background: rgba(37,211,102,0.15); color: #25d366; }
.dash-section-icon.ig { background: rgba(230,104,60,0.15); color: #e6683c; }
.dash-section-icon.fb { background: rgba(24,119,242,0.15); color: var(--accent-fb); }
.dash-section-count { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.dash-section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.dash-item-card { display: flex; align-items: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; cursor: pointer; transition: var(--tr); }
.dash-item-card:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.dash-item-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.dash-item-icon.wa-icon { background: rgba(37,211,102,0.15); color: #25d366; }
.dash-item-avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex-shrink: 0; border: 2px solid rgba(230,104,60,0.4); }
.dash-item-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dash-item-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.dash-item-name { font-size: 13px; font-weight: 600; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-item-status { font-size: 11px; }
.dash-item-status.connected { color: var(--green); }
.dash-item-status.disconnected { color: var(--text-3); }
.dash-item-arrow { color: var(--text-3); font-size: 11px; flex-shrink: 0; }
.dash-unlink-btn {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--text-3); font-size: 12px; padding: 5px 7px; cursor: pointer;
  flex-shrink: 0; transition: var(--tr); line-height: 1;
}
.dash-unlink-btn:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,.08); }
.dash-empty-inline { display: flex; align-items: center; gap: 10px; padding: 16px 20px; color: var(--text-3); font-size: 13px; background: var(--bg-card); border: 1px dashed var(--border); border-radius: 12px; grid-column: 1 / -1; }
.dash-empty-inline i { font-size: 18px; }

/* ============= ACCOUNT PREVIEW MODAL ============= */
.acc-preview-card { position: relative; width: 520px; max-width: 95vw; background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; animation: cardIn .25s ease-out; }
.acc-preview-close { position: absolute; top: 12px; right: 14px; z-index: 20; background: rgba(0,0,0,0.4); border: none; color: var(--text-2); width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; transition: var(--tr); }
.acc-preview-close:hover { color: var(--text-1); background: rgba(0,0,0,0.7); }
.acc-preview-blur { filter: blur(6px); pointer-events: none; user-select: none; opacity: 0.6; }
.acc-preview-gate { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px; text-align: center; background: rgba(10,14,20,0.75); backdrop-filter: blur(2px); }
.acc-preview-gate-icon { width: 64px; height: 64px; border-radius: 50%; background: rgba(0,168,132,0.12); border: 2px solid rgba(0,168,132,0.3); display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--accent); margin-bottom: 4px; }
.acc-preview-gate h3 { font-size: 18px; font-weight: 700; color: var(--text-1); }
.acc-preview-gate p { font-size: 13px; color: var(--text-2); max-width: 320px; line-height: 1.5; }

/* -- Code entry gate (user role) -- */
.acc-gate-code-form { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 300px; margin-top: 4px; }
.acc-gate-input-wrap { position: relative; width: 100%; }
.acc-gate-input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; pointer-events: none; }
.acc-gate-code-input {
  width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 9px; padding: 11px 14px 11px 34px; color: var(--text-1);
  font-family: var(--font); font-size: 14px; outline: none; letter-spacing: 2px;
  text-align: center; transition: var(--tr);
}
.acc-gate-code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.acc-gate-code-input::placeholder { letter-spacing: normal; color: var(--text-3); font-size: 12px; }
.acc-gate-error { font-size: 12px; color: #f87171; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.2); border-radius: 7px; padding: 7px 12px; width: 100%; text-align: center; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-6px); }
  40%,80%  { transform: translateX(6px); }
}
.shake { animation: shake 0.45s ease; }

/* -- Loading screen (after code verified) -- */
.acc-loading-screen { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 320px; }
.acc-loading-spinner {
  width: 52px; height: 52px; border-radius: 50%;
  border: 3px solid rgba(0,168,132,0.15);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.acc-loading-title { font-size: 17px; font-weight: 700; color: var(--text-1); }
.acc-loading-sub { font-size: 12px; color: var(--text-2); text-align: center; line-height: 1.5; max-width: 260px; }
.acc-loading-bar-wrap { width: 100%; height: 4px; background: rgba(255,255,255,0.07); border-radius: 4px; overflow: hidden; }
.acc-loading-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 4px; }
.acc-loading-steps { display: flex; flex-direction: column; gap: 7px; width: 100%; margin-top: 4px; }
.acc-load-step { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 7px; transition: color 0.3s; }
.acc-load-step.active { color: var(--accent); }
.acc-load-step.done { color: #22c55e; }
.acc-load-step.done i { color: #22c55e; }

/* ============= DASHBOARD (Vincular) ============= */
.dashboard-link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background:
    linear-gradient(rgba(10,14,20,0.9), rgba(10,14,20,0.95)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23128C7E' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.link-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 420px;
  max-width: 90vw;
}
.link-header {
  text-align: center;
  margin-bottom: 28px;
}
.link-header i {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 16px;
}
.link-header h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
}
.link-header p {
  font-size: 13px;
  color: var(--text-2);
}
.link-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.link-stats {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.link-stats span {
  font-size: 12px;
  color: var(--text-3);
}

/* ============= CLIENTES Layout ============= */
.clientes-layout {
  display: flex;
  height: 100%;
}
.clientes-sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.clientes-chats {
  width: 320px;
  background: var(--bg-content);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.clientes-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h3 { font-size: 16px; font-weight: 600; }

.chats-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.chats-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}
.client-tabs {
  display: flex;
  gap: 4px;
}
.tab-btn {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--tr);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.tab-btn:hover { background: var(--bg-card); }
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tab-btn i { font-size: 12px; }

.search-box-sm {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 12px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.search-box-sm i { color: var(--text-3); font-size: 13px; }
.search-box-sm input {
  flex: 1; background: transparent; border: none;
  color: var(--text-1); font-size: 13px; outline: none;
}
.search-box-sm input::placeholder { color: var(--text-3); }

.clients-list {
  flex: 1;
  overflow-y: auto;
}
.client-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(139,148,158,.08);
  transition: var(--tr);
}
.client-item:hover { background: var(--bg-card); }
.client-item.active { background: var(--bg-card-hover); }
.client-item.online .client-avatar { box-shadow: 0 0 0 2px var(--accent); }
.client-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-card-hover), var(--bg-card));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.client-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.client-avatar .avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.client-number-small {
  display: block;
  font-size: 10px;
  color: var(--text-3);
  margin-top: 1px;
}
.client-details { flex: 1; min-width: 0; }
.client-details h4 {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.client-status {
  font-size: 11px;
  color: var(--text-3);
  display: flex; align-items: center; gap: 4px;
  margin-top: 2px;
}
.client-status.online { color: var(--accent); }
.client-actions {
  display: flex; gap: 4px;
}
.client-actions .btn-sm { padding: 5px 8px; font-size: 11px; }

/* Legacy classes for compatibility */
.client-count { font-size: 12px; color: var(--text-3); }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 14px; text-transform: uppercase; letter-spacing: .5px; }

/* ============= AVATAR ============= */
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-card-hover), var(--bg-card));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  flex-shrink: 0; border: 1px solid var(--border);
}
.avatar.sm { width: 36px; height: 36px; font-size: 12px; }
.avatar.group { background: rgba(0,168,132,.1); color: var(--accent); }

/* ============= CHATS VIEW ============= */
.chats-layout { display: flex; height: 100%; }
.chats-sidebar {
  width: 340px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.client-selector {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px 10px; font-size: 13px; color: var(--text-2);
}
.client-selector select {
  flex: 1; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; color: var(--text-1);
  font-family: var(--font); font-size: 13px; outline: none;
}
.client-selector select:focus { border-color: var(--accent); }

.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer; border-bottom: 1px solid rgba(139,148,158,.06);
  transition: var(--tr);
}
.chat-item:hover { background: var(--bg-card); }
.chat-item.active { background: var(--bg-card-hover); }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-row { display: flex; justify-content: space-between; align-items: baseline; }
.chat-item-row:last-child { margin-top: 2px; }
.ci-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; margin-left: 8px; }
.ci-preview { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.badge-num { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; margin-left: 6px; }

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-3); gap: 8px; }
.chat-empty i { font-size: 56px; opacity: .3; }
.chat-empty h3 { font-size: 20px; color: var(--text-2); font-weight: 300; }

.chat-active { display: flex; flex-direction: column; height: 100%; }
.chat-top-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.chat-top-info { flex: 1; }
.chat-top-info h4 { font-size: 14px; font-weight: 600; }
.chat-top-info span { font-size: 11px; color: var(--text-3); }

/* ============= SYNC BAR ============= */
.sync-bar {
  padding: 8px 16px;
  background: rgba(0,168,132,.08);
  border-bottom: 1px solid rgba(0,168,132,.15);
  flex-shrink: 0;
}
.sync-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.sync-bar-inner span {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}
.sync-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(0,168,132,.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.sync-progress {
  height: 3px;
  background: rgba(0,168,132,.15);
  border-radius: 2px;
  overflow: hidden;
}
.sync-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}
.sync-bar.done .sync-spinner { display: none; }
.sync-bar.done .sync-bar-inner span { color: var(--green); }
.sync-bar.done .sync-progress-fill { background: var(--green); }

.messages-area {
  flex: 1; overflow-y: auto; padding: 16px 48px;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--bg-chat-area);
}
.msg {
  max-width: 60%; padding: 8px 12px; border-radius: 8px;
  font-size: 13px; line-height: 1.45; word-break: break-word;
  animation: msgIn .2s ease;
}
@keyframes msgIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }
.msg.sent { align-self: flex-end; background: #005c4b; border-bottom-right-radius: 2px; }
.msg.recv { align-self: flex-start; background: var(--bg-card); border-bottom-left-radius: 2px; }
.msg-text { display: block; }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 3px; font-size: 10px; color: rgba(255,255,255,.4); }
.msg-meta i { font-size: 11px; color: #53bdeb; }
.msg-media-tag { display: flex; align-items: center; gap: 6px; padding: 6px 10px; margin-bottom: 4px; background: rgba(0,0,0,.15); border-radius: 5px; font-size: 12px; color: var(--text-2); }
.msg-media-tag i { color: var(--accent); }
/* Mensaje llegado por Realtime — animación de entrada */
.msg.rt-new { animation: rtSlideIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes rtSlideIn { from { opacity:0; transform:translateY(10px) scale(0.97); } to { opacity:1; transform:translateY(0) scale(1); } }

.msg-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--bg-card); border-top: 1px solid var(--border);
}
.msg-input-bar input {
  flex: 1; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 14px; color: var(--text-1); font-family: var(--font); font-size: 13px; outline: none;
}
.msg-input-bar input:focus { border-color: var(--accent); }
.msg-input-bar input::placeholder { color: var(--text-3); }

.icon-btn {
  background: transparent; border: none; color: var(--text-3);
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; transition: var(--tr);
}
.icon-btn:hover { background: var(--bg-card); color: var(--text-2); }
.icon-btn.send:hover { color: var(--accent); }

/* ============= PLACEHOLDER VIEW ============= */
.placeholder-view { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-3); gap: 8px; }
.placeholder-view i { font-size: 48px; opacity: .3; }
.placeholder-view p { font-size: 16px; color: var(--text-2); }
.placeholder-view span { font-size: 13px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: var(--text-3); gap: 8px; text-align: center; }
.empty-state i { font-size: 32px; opacity: .4; }
.empty-state p { font-size: 14px; color: var(--text-2); }
.empty-state span { font-size: 12px; }
.empty-state.sm { padding: 24px; }
.empty-state.sm i { font-size: 24px; }

/* Connection Error */
.connection-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  margin: 10px;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius);
  text-align: center;
  gap: 8px;
}
.connection-error i { font-size: 28px; color: var(--red); opacity: 0.7; }
.connection-error h4 { font-size: 14px; color: var(--text-1); font-weight: 600; }
.connection-error p { font-size: 12px; color: var(--text-2); max-width: 280px; }
.error-solution {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.5;
  text-align: left;
}
.error-solution code {
  background: rgba(0, 168, 132, 0.15);
  color: var(--accent);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 10px;
}

/* ============= SETTINGS ============= */
.privacy-content { padding: 0 28px 28px; max-width: 600px; }
.cfg-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-1);
  font-size: 12px;
  font-family: var(--font);
  outline: none;
  transition: border-color .2s;
  box-sizing: border-box;
}
.cfg-input:focus { border-color: var(--accent); }

.config-content {
  padding: 24px 28px 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.cfg-col { display: flex; flex-direction: column; gap: 16px; }
.cfg-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cfg-panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .7px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.cfg-panel-title i { color: var(--accent); }
@media (max-width: 960px) {
  .config-content { grid-template-columns: 1fr; }
}
.setting-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px;
}
.setting-info h4 { font-size: 14px; font-weight: 600; }
.setting-info p { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; background: rgba(139,148,158,.1); color: var(--text-2); }
.badge.green { background: rgba(0,168,132,.15); color: var(--accent); }
.badge.red { background: rgba(239,68,68,.15); color: var(--red); }
.badge.yellow { background: rgba(245,158,11,.15); color: var(--yellow); }

.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: var(--text-3); border-radius: 12px; transition: var(--tr);
}
.slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: var(--tr);
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ============= MODAL ============= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s ease;
}
.modal-card {
  background: var(--bg-content); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 440px; max-width: 90vw;
  box-shadow: 0 12px 48px rgba(0,0,0,.5);
  animation: cardIn .3s ease-out;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-header h3 i { color: var(--accent); }
.modal-body { padding: 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--border);
}

.pairing-result { text-align: center; margin-top: 18px; }
.pairing-code {
  font-size: 32px; font-weight: 700; color: var(--accent); letter-spacing: 4px;
  padding: 18px; background: var(--bg-app); border-radius: 12px;
  border: 2px dashed rgba(0,168,132,.3); margin-bottom: 14px;
}
.pairing-hint { font-size: 13px; color: var(--text-2); line-height: 1.5; margin-bottom: 12px; }
.pairing-status { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.status-dot.online { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.status-dot.connecting { background: var(--yellow); animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ============= RESPONSIVE ============= */
/* ============= RULES SECTION ============= */
.rules-section {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.rules-section .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}
.rules-section .section-title i { font-size: 12px; }

/* ============= PAYWALL / ACCESS KEY ============= */
.clientes-right-wrap {
  position: relative;
  display: flex;
  flex: 1;
  overflow: hidden;
}

.paywall-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,14,20,.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.paywall-card {
  text-align: center;
  padding: 36px 32px;
  max-width: 380px;
  width: 90%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.paywall-card i.fa-lock {
  font-size: 36px;
  color: var(--accent);
  margin-bottom: 16px;
  filter: drop-shadow(0 0 12px rgba(0,168,132,.4));
}
.paywall-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 8px;
}
.paywall-card p {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 20px;
  line-height: 1.5;
}
.paywall-input {
  display: flex;
  gap: 8px;
}
.paywall-input input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-1);
  font-size: 13px;
  outline: none;
  transition: border-color .2s;
}
.paywall-input input:focus { border-color: var(--accent); }
.paywall-input .btn-primary {
  padding: 10px 18px;
  font-size: 13px;
  white-space: nowrap;
}

.chat-list.blurred {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

/* ── WhatsApp Web light mode simulation ─────────────────────────────────── */
.clientes-chats.sim-wa-mode {
  background: #ffffff;
  border-right: 1px solid #e9edef;
}
.clientes-chats.sim-wa-mode .chats-header,
.clientes-chats.sim-wa-mode .sidebar-header {
  background: #f0f2f5;
  border-color: #e9edef;
}
.clientes-chats.sim-wa-mode .chats-header h3,
.clientes-chats.sim-wa-mode .chats-header .tab-btn {
  color: #54656f;
}
.clientes-chats.sim-wa-mode .search-box-sm {
  background: #f0f2f5;
}
.clientes-chats.sim-wa-mode .search-box-sm input {
  background: #f0f2f5;
  color: #111b21;
}
.clientes-messages.sim-wa-mode {
  background: #efeae2;
}
.clientes-messages.sim-wa-mode .chat-empty {
  background: #f0f2f5;
}
.clientes-messages.sim-wa-mode .messages-area {
  background: #efeae2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Crect width='80' height='80' fill='%23efeae2'/%3E%3C/svg%3E");
}
.clientes-messages.sim-wa-mode .msg-input-bar {
  background: #f0f2f5;
  border-top: 1px solid #e9edef;
}
.clientes-messages.sim-wa-mode .msg-input-bar input {
  background: #ffffff;
  color: #111b21;
  border-color: #e9edef;
}
.clientes-messages.sim-wa-mode .msg-input-bar input::placeholder { color: #8696a0; }
.clientes-messages.sim-wa-mode .icon-btn { color: #54656f; }
.clientes-messages.sim-wa-mode .icon-btn:hover { background: rgba(84,101,111,.1); }

/* Paywall ring icon */
.paywall-lock-ring {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(0,168,132,.12);
  border: 2px solid rgba(0,168,132,.3);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 0 24px rgba(0,168,132,.2);
}
.paywall-lock-ring i {
  font-size: 26px;
  color: var(--accent);
}

/* Modules list (user role) */
.paywall-modules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.paywall-module-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.paywall-module-badge.locked {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text-2);
}
.paywall-module-badge.locked i {
  color: var(--text-3);
  font-size: 12px;
  width: 14px;
}

@media (max-width: 900px) {
  .icon-sidebar { width: 56px; }
  .nav-btn span { display: none; }
  .nav-btn { width: 44px; }
  .chats-sidebar { width: 260px; }
  .dashboard-sidebar { width: 260px; }
  .messages-area { padding: 12px 16px; }
}
@media (max-width: 640px) {
  .icon-sidebar { width: 48px; }
  .sidebar-logo { width: 32px; height: 32px; font-size: 16px; border-radius: 8px; }
  .chats-layout { flex-direction: column; }
  .chats-sidebar { width: 100%; max-height: 40vh; }
  .dashboard-wa { flex-direction: column; }
  .dashboard-sidebar { width: 100%; max-height: 50vh; }
  .dashboard-main { display: none; }
}

/* ============= MEDIA MESSAGES ============= */
.msg-media {
  display: block;
  max-width: 280px;
  max-height: 300px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  object-fit: contain;
  background: rgba(0,0,0,0.2);
}
audio.msg-media {
  width: 240px;
  height: 36px;
  max-height: unset;
}
video.msg-media {
  max-width: 280px;
  max-height: 200px;
}
.msg-media-fetch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0,168,132,0.12);
  border: 1px solid var(--accent);
  border-radius: 20px;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background .2s;
  text-decoration: none;
}
.msg-media-fetch:hover { background: rgba(0,168,132,0.22); }
.msg-media-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 4px;
}

/* ============= SETTINGS LOCK ============= */
.settings-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 16px;
  text-align: center;
}
.settings-lock i { font-size: 48px; color: var(--text-3); }
.settings-lock h3 { margin: 0; font-size: 18px; }
.settings-lock p { margin: 0; color: var(--text-2); font-size: 13px; }
.settings-lock .input-group { width: 100%; max-width: 300px; }

/* ============= USER MANAGEMENT ============= */
.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.user-card-info { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.user-card-name { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.user-card-instances { display: flex; flex-wrap: wrap; gap: 4px; }
.user-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

.user-instance-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0,168,132,.12);
  color: var(--accent);
  border: 1px solid rgba(0,168,132,.2);
}

.btn-sm-danger {
  background: rgba(239,68,68,.1);
  color: #ef4444;
  border-color: rgba(239,68,68,.2);
}
.btn-sm-danger:hover { background: rgba(239,68,68,.2); }

.btn-sm-save {
  background: rgba(0,168,132,.1);
  color: var(--accent);
  border-color: rgba(0,168,132,.2);
  font-size: 11px;
  padding: 3px 10px;
  white-space: nowrap;
}
.btn-sm-save:hover { background: rgba(0,168,132,.2); }

.user-instances-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.user-instance-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-1);
}
.user-instance-check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ============= SIMULATED INSTANCES ============= */

/* Inline badge inside client list */
.sim-badge-inline {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(139,92,246,.18);
  color: #a78bfa;
  border: 1px solid rgba(139,92,246,.25);
  letter-spacing: .3px;
  vertical-align: middle;
}

/* Card in config panel */
.sim-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.sim-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.sim-card-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
}
.sim-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(139,92,246,.18);
  color: #a78bfa;
  border: 1px solid rgba(139,92,246,.25);
  letter-spacing: .4px;
  flex-shrink: 0;
}
.sim-services {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sim-svc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(139,148,158,.07);
  gap: 8px;
}
.sim-svc-row:last-child { border-bottom: none; }
.sim-svc-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-2);
}
.sim-svc-label i { color: var(--accent); font-size: 11px; width: 14px; }

/* ── Simulado: loading sequence ───────────────────────────── */
.sim-loading-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.sim-loading-header {
  display: flex;
  align-items: center;
  gap: 16px;
}
.sim-loading-ring {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(0,168,132,.15);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
  flex-shrink: 0;
}
.sim-loading-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}
.sim-loading-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
}
.sim-loading-stages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sim-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-3);
  transition: color .3s;
}
.sim-stage.done   { color: var(--accent); }
.sim-stage.active { color: var(--text-1); font-weight: 600; }
.sim-stage-icon { width: 16px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.sim-stage-spinner {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(0,168,132,.2);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
  display: inline-block;
}
.sim-stage-dots { display:flex; gap:2px; }
.sim-stage-dots span {
  animation: dotBlink 1.2s infinite;
  font-size: 16px;
  line-height: 1;
  color: var(--accent);
}
.sim-stage-dots span:nth-child(2) { animation-delay: .2s; }
.sim-stage-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dotBlink { 0%,80%,100%{opacity:.2} 40%{opacity:1} }
.sim-loading-note {
  font-size: 11px;
  color: var(--text-3);
  background: rgba(255,200,80,.06);
  border: 1px solid rgba(255,200,80,.12);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.5;
}
.sim-loading-note i { color: #f5c842; margin-top: 2px; flex-shrink: 0; }
.sim-loading-bar-wrap {
  background: rgba(255,255,255,.06);
  border-radius: 99px;
  height: 4px;
  overflow: hidden;
}
.sim-loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #34d399);
  border-radius: 99px;
  width: 0%;
  transition: width .8s ease;
}
.sim-sync-done-ring {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(0,168,132,.12);
  border: 2px solid rgba(0,168,132,.35);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px;
}
.sim-sync-done-ring i { font-size: 26px; color: var(--accent); }

/* Active module badge (simulated paywall) */
.paywall-module-badge.active {
  background: rgba(0,168,132,.12);
  border: 1px solid rgba(0,168,132,.25);
  color: var(--accent);
}
.paywall-module-badge.active i { color: var(--accent); font-size: 12px; width: 14px; }

/* ======================== EXPORT MODAL ======================== */
.export-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.export-modal-overlay.hidden { display: none; }
.export-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 460px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.export-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.export-modal-header h3 { font-size: 15px; font-weight: 600; }
.export-modal-header p  { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.export-scope-label {
  font-size: 12px; color: var(--accent);
  background: rgba(0,168,132,.1); border: 1px solid rgba(0,168,132,.2);
  border-radius: 6px; padding: 6px 10px; white-space: nowrap;
}
.export-options { display: flex; flex-direction: column; gap: 14px; }
.export-option-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.export-option-row label { font-size: 13px; color: var(--text-1); }
.export-option-row small { font-size: 11px; color: var(--text-2); display: block; margin-top: 2px; }
.export-select {
  background: var(--bg-input); color: var(--text-1);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; cursor: pointer; min-width: 150px;
}
.export-checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.export-checkbox-row input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.export-checkbox-row span { font-size: 13px; }
.export-progress { display: flex; flex-direction: column; gap: 10px; }
.export-progress.hidden { display: none; }
.export-bar-wrap { height: 6px; background: rgba(255,255,255,.07); border-radius: 99px; overflow: hidden; }
.export-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #34d399);
  border-radius: 99px; width: 0%; transition: width .4s ease;
}
.export-log { font-size: 12px; color: var(--text-2); min-height: 18px; }
.export-done { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.export-done.hidden { display: none; }
.export-done-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(0,168,132,.12); border: 2px solid rgba(0,168,132,.3);
  display: flex; align-items: center; justify-content: center;
}
.export-done-icon i { font-size: 22px; color: var(--accent); }
.export-done h4 { font-size: 14px; font-weight: 600; }
.export-done small { font-size: 11px; color: var(--text-2); }
.export-modal-footer { display: flex; gap: 8px; justify-content: flex-end; }
.btn-export-chat {
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,168,132,.1); color: var(--accent);
  border: 1px solid rgba(0,168,132,.2);
  border-radius: 6px; padding: 5px 10px; font-size: 11px; font-weight: 500;
  cursor: pointer; transition: background var(--tr); white-space: nowrap;
}
.btn-export-chat:hover { background: rgba(0,168,132,.22); }

/* ======================== SIMULATED DEMO STYLES ======================== */

/* Colored avatar circle for fake chat rows */
.sim-avatar-circle {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  flex-shrink: 0; min-width: 40px;
}

/* Typing indicator ("escribiendo...") */
.sim-typing { font-size: 12px; color: var(--accent); display: flex; align-items: baseline; gap: 1px; }
.td {
  display: inline-block;
  animation: simTypingBounce 1.1s infinite ease-in-out;
  font-weight: 700; font-size: 13px;
}
.td:nth-child(2) { animation-delay: 0.18s; }
.td:nth-child(3) { animation-delay: 0.36s; }
@keyframes simTypingBounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
  40%           { transform: translateY(-3px); opacity: 1;   }
}

/* Unread count badge */
.sim-unread-badge {
  background: var(--accent); color: #fff; border-radius: 999px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; margin-left: 4px;
}

/* Sync duration number input in sim card */
.sim-duration-input {
  width: 64px; padding: 4px 8px;
  background: var(--bg-input); color: var(--text-1);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; text-align: center;
}
.sim-duration-input:focus { outline: none; border-color: var(--accent); }
.sim-duration-select {
  background: var(--bg-input); color: var(--text-1);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 6px; font-size: 12px; cursor: pointer;
}
.sim-duration-select:focus { outline: none; border-color: var(--accent); }
