/* ==========================================================================
   WHATSELLER & VALLEY PARK ADMIN PLATFORM
   Ultra-Modern SaaS Design System (Dual Theme: Dark & Light Mode)
   Version: 3.1 (2026-09-21)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS VARIABLES & THEME TOKENS
   -------------------------------------------------------------------------- */

:root {
  /* Brand Accents & Semantics */
  --primary: #10B981;
  --primary-hover: #059669;
  --primary-dark: #047857;
  --primary-glow: rgba(16, 185, 129, 0.22);
  --primary-subtle: rgba(16, 185, 129, 0.12);
  --primary-gradient: linear-gradient(135deg, #10B981 0%, #06B6D4 100%);
  --primary-gradient-subtle: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(6, 182, 212, 0.1) 100%);
  
  --cyan: #06B6D4;
  --blue: #3B82F6;
  --blue-glow: rgba(59, 130, 246, 0.2);
  --purple: #8B5CF6;
  --purple-glow: rgba(139, 92, 246, 0.2);
  --amber: #F59E0B;
  --amber-glow: rgba(245, 158, 11, 0.2);
  --red: #EF4444;
  --red-glow: rgba(239, 68, 68, 0.2);
  
  /* Legacy alias variables */
  --accent: var(--primary);
  --accent-dark: var(--primary-hover);
  --accent-glow: var(--primary-glow);
  --orange: var(--amber);

  /* Geometry & Layout */
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   DARK THEME (Default / Night Mode)
   -------------------------------------------------------------------------- */
:root,
:root[data-theme="dark"] {
  --theme: dark;
  --bg: #0B0F19;
  --bg-2: #0F172A;
  --bg-3: #141E33;
  --surface: #162038;
  --surface-2: #1E2B4A;
  --surface-hover: #223257;
  --surface-elevated: #1E294B;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);
  --border-strong: rgba(255, 255, 255, 0.28);
  
  --text: #F8FAFC;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  --text-inverse: #0F172A;
  --text-bright: #FFFFFF;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 30px rgba(16, 185, 129, 0.15);

  --card-bg: rgba(22, 32, 56, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --modal-backdrop: rgba(6, 10, 20, 0.82);
  --table-stripe: rgba(255, 255, 255, 0.02);
  --table-hover: rgba(255, 255, 255, 0.05);

  --chat-bg: #0C1222;
  --chat-msg-in: #1A253E;
  --chat-msg-in-border: rgba(255, 255, 255, 0.08);
  --chat-msg-out: linear-gradient(135deg, #15803D 0%, #166534 100%);
  --chat-msg-out-human: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
}

/* --------------------------------------------------------------------------
   LIGHT THEME (Day Mode / Clean Slate)
   -------------------------------------------------------------------------- */
:root[data-theme="light"] {
  --theme: light;
  --bg: #F8FAFC;
  --bg-2: #FFFFFF;
  --bg-3: #F1F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-hover: #F1F5F9;
  --surface-elevated: #FFFFFF;
  --border: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(15, 23, 42, 0.16);
  --border-strong: rgba(15, 23, 42, 0.28);
  
  --text: #0F172A;
  --text-dim: #475569;
  --text-muted: #64748B;
  --text-inverse: #FFFFFF;
  --text-bright: #0F172A;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.12);

  --card-bg: #FFFFFF;
  --card-border: rgba(15, 23, 42, 0.08);
  --modal-backdrop: rgba(15, 23, 42, 0.55);
  --table-stripe: rgba(248, 250, 252, 0.7);
  --table-hover: rgba(241, 245, 249, 0.85);

  --chat-bg: #F1F5F9;
  --chat-msg-in: #FFFFFF;
  --chat-msg-in-border: rgba(15, 23, 42, 0.08);
  --chat-msg-out: linear-gradient(135deg, #10B981 0%, #059669 100%);
  --chat-msg-out-human: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
}

/* --------------------------------------------------------------------------
   2. GLOBAL RESETS & BASE
   -------------------------------------------------------------------------- */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Structural transition support */
.sidebar, .main-content, .topbar, .card, .stat-card, .conv-list, .conv-chat,
.chat-header, .chat-input-area, .modal-box, .data-table, .user-row, .knowledge-item,
.template-card, .campaign-card, .quality-card {
  transition: background-color var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal), color var(--transition-normal);
}

/* --------------------------------------------------------------------------
   3. LOGIN SCREEN
   -------------------------------------------------------------------------- */

#login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(16, 185, 129, 0.15) 0%, var(--bg) 75%);
  z-index: 1000;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px var(--primary-glow);
  object-fit: cover;
}

.logo-leaf {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}

.login-logo h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.login-logo p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   4. APP LAYOUT
   -------------------------------------------------------------------------- */

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg);
}

/* --------------------------------------------------------------------------
   5. TOPBAR GLOBAL
   -------------------------------------------------------------------------- */

.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.topbar-breadcrumb .sep {
  opacity: 0.4;
}

.topbar-breadcrumb .current {
  color: var(--text);
  font-weight: 600;
}

.topbar-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-subtle);
  border: 1px solid var(--primary-glow);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 600;
}

.status-dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  animation: livePulse 2s infinite ease-in-out;
}

@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.theme-toggle-btn .theme-icon {
  font-size: 1rem;
  line-height: 1;
}

/* User Quick Profile Pill */
.topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 6px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.topbar-profile:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.topbar-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   6. SIDEBAR
   -------------------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 30;
  user-select: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: 0 4px 14px var(--primary-glow);
  object-fit: cover;
}

.sidebar-brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.sidebar-brand-text span {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 12px 4px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
  position: relative;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.nav-item.active {
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: 600;
  border-color: var(--primary-glow);
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.06);
}

.nav-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
}

.nav-badge {
  position: absolute;
  top: 7px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  background: var(--red);
  color: #FFFFFF;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.user-info:hover {
  background: var(--surface);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--primary-glow);
}

#sidebar-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.sidebar-footer-actions {
  display: flex;
  gap: 8px;
}

.btn-sidebar-tool {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-sidebar-tool:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-hover);
}

.btn-logout {
  width: 100%;
  padding: 8px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   7. MAIN CONTENT & HEADERS
   -------------------------------------------------------------------------- */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg);
  min-width: 0;
}

.tab-section {
  display: none;
  padding: 28px 32px;
  min-height: 100%;
  animation: fadeIn 0.2s ease-out;
}

.tab-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header, .content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2, .content-header h2 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.2;
}

.page-header p, .content-header p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   8. BUTTONS
   -------------------------------------------------------------------------- */

.btn-primary {
  background: var(--primary-gradient);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 10px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--primary-glow);
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.btn-full {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-xs);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.08);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-filter {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-filter:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-hover);
}

.btn-filter.active {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary-glow);
}

.quick-action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.quick-action-btn:hover {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary-glow);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   9. FORMS & INPUTS
   -------------------------------------------------------------------------- */

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.field-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.field-group small {
  font-weight: 400;
  color: var(--text-muted);
}

input[type=text],
input[type=password],
input[type=email],
input[type=number],
input[type=datetime-local],
input[type=date],
select,
textarea {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  width: 100%;
  transition: all var(--transition-fast);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surface);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select option {
  background: var(--surface);
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.char-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 2px;
}

.error-msg {
  color: var(--red);
  font-size: 0.82rem;
  text-align: center;
  margin-top: 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

/* --------------------------------------------------------------------------
   10. STAT CARDS & METRICS (KPIs)
   -------------------------------------------------------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-hover);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.stat-body {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 4px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.mini-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.mini-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.mini-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   11. CHARTS & VISUALS
   -------------------------------------------------------------------------- */

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.chart-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.chart-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 140px;
  padding-top: 16px;
  border-bottom: 1px solid var(--border);
}

.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  background: var(--primary-gradient);
  border-radius: 6px 6px 0 0;
  min-height: 6px;
  transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  cursor: pointer;
}

.chart-bar:hover {
  filter: brightness(1.15);
}

.chart-bar:hover::after {
  content: attr(data-count);
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 10;
}

.chart-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   12. CONVERSATIONS & LIVE CHAT (WhatsApp Web Style)
   -------------------------------------------------------------------------- */

#tab-conversations {
  display: none;
  padding: 20px 24px;
  height: calc(100vh - var(--topbar-h));
  flex-direction: column;
}

#tab-conversations.active {
  display: flex;
}

.conv-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  flex: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  height: calc(100vh - var(--topbar-h) - 40px);
  min-height: 520px;
  box-shadow: var(--shadow);
  background: var(--surface);
}

.conv-list {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

.conv-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.conv-item:hover {
  background: var(--surface-hover);
}

.conv-item.active {
  background: var(--primary-subtle) !important;
  border-left: 3px solid var(--primary) !important;
}

.conv-unread {
  border-left: 3px solid var(--primary) !important;
  background: var(--primary-subtle) !important;
}

.conv-item-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.conv-avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: 0 4px 12px var(--primary-glow);
  flex-shrink: 0;
}

.conv-item-content {
  flex: 1;
  min-width: 0;
}

.conv-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}

.conv-phone {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
}

.conv-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.conv-preview {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.conv-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conv-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 600;
}

.status-bot {
  background: rgba(16, 185, 129, 0.14);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-human {
  background: rgba(245, 158, 11, 0.14);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.conv-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  padding: 0 6px;
  line-height: 1;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Chat Canvas */
.conv-chat {
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-bubble {
  max-width: 68%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}

.msg-in {
  background: var(--chat-msg-in);
  border: 1px solid var(--chat-msg-in-border);
  color: var(--text);
  align-self: flex-start;
  border-top-left-radius: 3px;
}

.msg-out {
  background: var(--chat-msg-out);
  color: #FFFFFF;
  align-self: flex-end;
  border-top-right-radius: 3px;
}

.msg-out.human-msg {
  background: var(--chat-msg-out-human);
}

.msg-content {
  word-break: break-word;
}

.msg-sender {
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.75;
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}

.msg-time {
  font-size: 0.68rem;
  opacity: 0.65;
  margin-top: 4px;
  text-align: right;
}

/* Chat Input Bar */
.chat-input-area {
  padding: 12px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.chat-textarea {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  resize: none;
  line-height: 1.5;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  transition: border-color var(--transition-fast);
  overflow-y: auto;
}

.chat-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surface);
}

.chat-tool-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.chat-tool-btn:hover {
  color: var(--primary);
  background: var(--primary-subtle);
  border-color: var(--primary-glow);
}

.mic-btn.recording {
  color: var(--red) !important;
  background: rgba(239, 68, 68, 0.15) !important;
  animation: pulse-mic 1s ease-in-out infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--primary-gradient);
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 12px var(--primary-glow);
  transition: all var(--transition-fast);
}

.chat-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 5px 18px var(--primary-glow);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

/* Audio Recording Bar */
.audio-recording-bar {
  padding: 12px 18px;
  background: var(--surface);
  border-top: 1px solid rgba(239, 68, 68, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--red);
  font-weight: 600;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  animation: rec-blink 1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* Emoji Panel */
.emoji-panel {
  padding: 8px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
}

.emoji-search-wrap {
  padding: 0 4px;
}

.emoji-search {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  font-family: var(--font);
}

.emoji-search:focus {
  border-color: var(--primary);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 2px;
  overflow-y: auto;
  max-height: 180px;
}

.emoji-btn {
  width: 36px;
  height: 36px;
  font-size: 1.25rem;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
  line-height: 1;
}

.emoji-btn:hover {
  background: var(--surface-hover);
}

/* --------------------------------------------------------------------------
   13. DATA TABLES & CONTAINERS
   -------------------------------------------------------------------------- */

.card, .panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.table-container, .table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table thead th {
  background: var(--bg-3);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--table-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   14. BADGES, CSAT & CRM TAGS
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.variant-badge {
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: var(--radius-xs);
  padding: 2px 7px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  display: inline-block;
}

.converted-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-subtle);
  border: 1px solid var(--primary-glow);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  display: inline-block;
}

/* CSAT Cards */
.csat-card-premium {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.csat-card-premium:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-hover);
}

.csat-progress-container {
  width: 100%;
  height: 8px;
  background: var(--bg-3);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 10px;
}

.csat-progress-bar {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   15. QUALIDADE DO NÚMERO (WHATSAPP QUALITY)
   -------------------------------------------------------------------------- */

.quality-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}

.quality-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.quality-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.quality-phone {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.rating-badge {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
}

.rating-GREEN {
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.rating-YELLOW {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.rating-RED {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.rating-unknown {
  background: var(--bg-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.quality-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.q-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.q-item span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.q-item strong {
  font-size: 0.98rem;
  color: var(--text);
}

.meta-warning {
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--amber);
}

.quality-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   16. TEMPLATES
   -------------------------------------------------------------------------- */

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.template-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.template-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.template-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
}

.template-status {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.status-DRAFT {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.status-PENDING {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-APPROVED {
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-glow);
}

.status-REJECTED {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.template-body {
  font-size: 0.84rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.template-tag {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.template-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   17. CAMPAIGNS & DISPAROS
   -------------------------------------------------------------------------- */

.info-banner {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 0.84rem;
  color: var(--blue);
  margin-bottom: 20px;
}

.warning-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--amber);
  margin-bottom: 20px;
}

.cost-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 40px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.cost-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cost-item span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cost-item strong {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.cost-highlight {
  color: var(--amber) !important;
}

.campaigns-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.campaign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.campaign-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.campaign-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.campaign-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.campaign-progress {
  margin-bottom: 16px;
}

.progress-bar {
  height: 7px;
  background: var(--bg-3);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.progress-stats {
  display: flex;
  gap: 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.progress-stats span strong {
  color: var(--text);
}

.campaign-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.campaign-cost {
  font-size: 0.82rem;
}

.campaign-cost .label {
  color: var(--text-muted);
}

.campaign-cost .value {
  font-weight: 700;
  color: var(--amber);
}

.campaign-actions {
  display: flex;
  gap: 8px;
}

.camp-estimate {
  background: var(--primary-subtle);
  border: 1px solid var(--primary-glow);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 10px;
}

.estimate-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 4px 0;
  color: var(--text-dim);
}

.estimate-row strong {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   18. KNOWLEDGE BASE
   -------------------------------------------------------------------------- */

.knowledge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.knowledge-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.knowledge-item:hover {
  border-color: var(--border-hover);
}

.knowledge-category {
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-glow);
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.knowledge-body {
  flex: 1;
  min-width: 0;
}

.knowledge-question {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 4px;
}

.knowledge-answer {
  font-size: 0.84rem;
  color: var(--text-dim);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.knowledge-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   19. USERS MANAGEMENT
   -------------------------------------------------------------------------- */

.users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.user-row-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #FFFFFF;
  flex-shrink: 0;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.user-row-body {
  flex: 1;
}

.user-row-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.user-row-username {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.user-last-login {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.user-actions {
  display: flex;
  gap: 8px;
}

.role-badge {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-block;
}

.role-super_admin {
  background: rgba(139, 92, 246, 0.15);
  color: #A78BFA;
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.role-admin {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.role-attendant {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

/* --------------------------------------------------------------------------
   20. MODALS
   -------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(10px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.modal-sm {
  max-width: 460px;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-2);
}

.msg-preview {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  min-height: 60px;
  color: var(--text);
  white-space: pre-wrap;
}

/* --------------------------------------------------------------------------
   21. TOASTS & SCROLLBARS
   -------------------------------------------------------------------------- */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success {
  border-left: 4px solid var(--primary);
}

.toast.error {
  border-left: 4px solid var(--red);
}

.toast.info {
  border-left: 4px solid var(--blue);
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .conv-layout { grid-template-columns: 280px 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 64px; }
  .sidebar-brand-text, .sidebar-section-title, #sidebar-username, .sidebar-role { display: none; }
  .nav-item span:not(.nav-icon):not(.badge) { display: none; }
  .topbar { padding: 0 16px; }
  .conv-layout { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   22. RESERVATIONS & TICKETS TIMELINE BY DATE
   -------------------------------------------------------------------------- */

.res-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.res-tabs-switch {
  display: flex;
  gap: 6px;
  background: var(--bg-3);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.res-tab-btn {
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.res-tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.res-timeline-container {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.res-date-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}

.res-date-group:hover {
  border-color: var(--border-hover);
}

.res-date-header {
  padding: 14px 20px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.res-date-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
}

.res-date-pill {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.pill-upcoming {
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-glow);
}

.pill-past {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.res-date-summary {
  font-size: 0.82rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 12px;
}

.res-date-summary strong {
  color: var(--text);
}

.res-cards-list {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.res-card-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}

.res-card-item:hover {
  transform: translateY(-2px);
  border-color: var(--primary-glow);
  box-shadow: var(--shadow);
}

.res-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.res-client-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.res-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.res-client-names {
  min-width: 0;
}

.res-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.res-phone {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.res-time-pill {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-subtle);
  border: 1px solid var(--primary-glow);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.res-details-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--bg-3);
  padding: 8px 12px;
  border-radius: var(--radius-xs);
}

.res-details-box span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.res-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.res-code {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-open-chat {
  background: rgba(34, 197, 94, 0.12);
  color: var(--primary);
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 5px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
}

.btn-open-chat:hover {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* ==========================================================================
   VISUALIZAÇÃO DE MÍDIA & LIGHTBOX (FOTOS E COMPROVANTES)
   ========================================================================== */
.chat-img-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  margin-bottom: 6px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-img-container:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.chat-img-thumb {
  display: block;
  max-width: 280px;
  max-height: 240px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.chat-img-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  color: #ffffff;
  font-size: 0.72rem;
  padding: 8px 8px 4px;
  text-align: center;
  opacity: 0.9;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Modal Lightbox */
.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}

.lightbox-content {
  background: var(--surface, #1e2420);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius, 12px);
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  gap: 12px;
}

.lightbox-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text, #fff);
}

.lightbox-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lightbox-close-btn {
  background: none;
  border: none;
  color: var(--text-muted, #aaa);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color var(--transition-fast);
}

.lightbox-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.lightbox-body {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  max-height: calc(92vh - 65px);
}

.lightbox-body img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Card de Documento / PDF */
.msg-doc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  max-width: 300px;
}

.doc-icon {
  font-size: 1.5rem;
}

.doc-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.doc-type {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.doc-btn-download {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(34, 197, 94, 0.15);
  padding: 4px 10px;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.doc-btn-download:hover {
  background: var(--primary);
  color: #fff;
}

/* Player de Áudio nas mensagens */
.msg-audio-player {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}

.msg-audio-player audio {
  max-width: 240px;
  height: 38px;
}

.msg-audio-caption {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Barra de Gravação de Áudio */
.btn-send-rec {
  background: #22c55e !important;
  color: #fff !important;
  border: none !important;
  padding: 4px 12px !important;
  border-radius: 4px !important;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  margin-left: 8px !important;
  transition: background var(--transition-fast);
}

.btn-send-rec:hover {
  background: #16a34a !important;
}

