@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── TOKENS ────────────────────────────────────────────── */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22253a;
  --surface3: #2a2e45;
  --border: #2e3250;
  --accent: #137fec;
  --accent-h: #1a8fff;
  --accent-dim: #0d5bae;
  --green: #25d366;
  --yellow: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --text: #f0f2f8;
  --text2: #a0a8c2;
  --text3: #6b738f;
  --radius: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .4);
  --sidebar-w: 240px;
  --sidebar-c: 64px;
  --transition: .18s ease;
}

/* ── RESET ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none
}

button {
  cursor: pointer;
  font-family: inherit
}

img {
  max-width: 100%
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px
}

::-webkit-scrollbar-track {
  background: transparent
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px
}

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-wrap {
  display: flex;
  height: 100vh;
  overflow: hidden
}

.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-width: 0
}

.page-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto
}

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  flex-shrink: 0;
  position: relative;
  z-index: 100
}

.sidebar.collapsed {
  width: var(--sidebar-c)
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0
}

.sidebar-logo .logo-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition)
}

.sidebar.collapsed .logo-text {
  opacity: 0;
  width: 0
}

.sidebar-toggle {
  position: absolute;
  right: -12px;
  top: 52px;
  width: 24px;
  height: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text2);
  transition: var(--transition)
}

.sidebar-toggle:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent)
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden
}

.nav-section {
  margin-bottom: 4px
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 8px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition)
}

.sidebar.collapsed .nav-section-label {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius);
  color: var(--text2);
  transition: var(--transition);
  position: relative;
  white-space: nowrap
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text)
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(19, 127, 236, .25), rgba(19, 127, 236, .1));
  color: var(--accent);
  border: 1px solid rgba(19, 127, 236, .2)
}

.nav-item .nav-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center
}

.nav-item .nav-label {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  transition: opacity var(--transition), width var(--transition)
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0
}

.nav-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: auto;
  flex-shrink: 0;
  transition: opacity var(--transition)
}

.sidebar.collapsed .nav-badge {
  opacity: 0
}

.sidebar-footer {
  padding: 16px 8px;
  border-top: 1px solid var(--border)
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition)
}

.sidebar-user:hover {
  background: var(--surface2)
}

.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition)
}

.sidebar-user .user-role {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition)
}

.sidebar.collapsed .user-name,
.sidebar.collapsed .user-role {
  opacity: 0;
  width: 0
}

.sidebar-tooltip {
  display: none;
  position: absolute;
  left: calc(var(--sidebar-c) + 8px);
  background: var(--surface2);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid var(--border);
  pointer-events: none;
  z-index: 200;
  box-shadow: var(--shadow)
}

.sidebar.collapsed .nav-item:hover .sidebar-tooltip {
  display: block
}

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50
}

.topbar-left h1 {
  font-size: 20px;
  font-weight: 700
}

.topbar-left p {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
  position: relative
}

.topbar-btn:hover {
  background: var(--surface3);
  color: var(--text)
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--surface)
}

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition)
}

.card:hover {
  border-color: var(--surface3)
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px
}

.card-title {
  font-size: 15px;
  font-weight: 600
}

.card-subtitle {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
  position: relative;
  overflow: hidden
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dim))
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent-dim)
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 4px
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1
}

.stat-label {
  font-size: 12px;
  color: var(--text2)
}

.stat-delta {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px
}

.delta-up {
  color: var(--green)
}

.delta-down {
  color: var(--red)
}

/* ── GRID ───────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 16px
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr)
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr)
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr)
}

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr))
}

@media(max-width:1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr)
  }
}

@media(max-width:768px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr
  }

  .page-body {
    padding: 16px
  }
}

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px
}

.btn-primary {
  background: var(--accent);
  color: #fff
}

.btn-primary:hover {
  background: var(--accent-h)
}

.btn-success {
  background: var(--green);
  color: #fff
}

.btn-success:hover {
  filter: brightness(1.1)
}

.btn-danger {
  background: var(--red);
  color: #fff
}

.btn-danger:hover {
  filter: brightness(1.1)
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border)
}

.btn-outline:hover {
  background: var(--surface2);
  border-color: var(--text2)
}

.btn-ghost {
  background: transparent;
  color: var(--text2)
}

.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text)
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius)
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  padding: 0;
  justify-content: center;
  border-radius: 6px;
  font-size: 13px
}

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600
}

.badge-success {
  background: rgba(37, 211, 102, .15);
  color: var(--green);
  border: 1px solid rgba(37, 211, 102, .25)
}

.badge-warning {
  background: rgba(245, 158, 11, .15);
  color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, .25)
}

.badge-danger {
  background: rgba(239, 68, 68, .15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, .25)
}

.badge-primary {
  background: rgba(19, 127, 236, .15);
  color: var(--accent);
  border: 1px solid rgba(19, 127, 236, .25)
}

.badge-secondary {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border)
}

.badge-info {
  background: rgba(6, 182, 212, .15);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, .25)
}

.badge-purple {
  background: rgba(139, 92, 246, .15);
  color: var(--purple);
  border: 1px solid rgba(139, 92, 246, .25)
}

/* ── FORMS ──────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2)
}

.form-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 13px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: var(--transition);
  width: 100%
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(19, 127, 236, .15)
}

.form-control::placeholder {
  color: var(--text3)
}

.form-control-sm {
  padding: 6px 10px;
  font-size: 12px
}

.input-group {
  display: flex;
  gap: 0
}

.input-group .form-control {
  border-radius: var(--radius) 0 0 var(--radius)
}

.input-group .btn {
  border-radius: 0 var(--radius) var(--radius) 0;
  flex-shrink: 0
}

textarea.form-control {
  resize: vertical;
  min-height: 80px
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236b738f' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 10px) center;
  padding-right: 32px
}

.form-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer
}

.switch {
  position: relative;
  width: 42px;
  height: 24px
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--surface3);
  border-radius: 24px;
  transition: var(--transition)
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition)
}

.switch input:checked~.switch-slider {
  background: var(--accent)
}

.switch input:checked~.switch-slider::before {
  transform: translateX(18px)
}

/* ── TABLE ──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border)
}

table {
  width: 100%;
  border-collapse: collapse
}

thead tr {
  border-bottom: 1px solid var(--border)
}

thead th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text3);
  text-align: left;
  white-space: nowrap;
  background: var(--surface)
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition)
}

tbody tr:last-child {
  border-bottom: none
}

tbody tr:hover {
  background: var(--surface2)
}

tbody td {
  padding: 12px 16px;
  font-size: 13px
}

/* ── AVATAR ─────────────────────────────────────────────── */
.avatar {
  position: relative;
  display: inline-flex;
  flex-shrink: 0
}

.avatar-img,
.avatar-initials {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0
}

.avatar-sm .avatar-img,
.avatar-sm .avatar-initials {
  width: 32px;
  height: 32px;
  font-size: 12px
}

.avatar-lg .avatar-img,
.avatar-lg .avatar-initials {
  width: 52px;
  height: 52px;
  font-size: 18px
}

.avatar-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--green)
}

.avatar-dot.away {
  background: var(--yellow)
}

.avatar-dot.offline {
  background: var(--text3)
}

/* ── CHAT LAYOUT ────────────────────────────────────────── */
.chat-layout {
  display: flex;
  height: calc(100vh - 65px);
  overflow: hidden
}

.chat-sidebar {
  width: 320px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0
}

.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border)
}

.chat-search {
  position: relative
}

.chat-search .form-control {
  padding-left: 36px
}

.chat-search .bi {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 16px;
  pointer-events: none
}

.chat-filters {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap
}

.filter-chip {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text2);
  background: transparent;
  cursor: pointer;
  transition: var(--transition)
}

.filter-chip.active,
.filter-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent)
}

.chat-list {
  flex: 1;
  overflow-y: auto
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  position: relative
}

.chat-item:hover {
  background: var(--surface2)
}

.chat-item.active {
  background: rgba(19, 127, 236, .1);
  border-right: 2px solid var(--accent)
}

.chat-item-body {
  flex: 1;
  min-width: 0
}

.chat-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px
}

.chat-item-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.chat-item-time {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
  margin-left: 8px
}

.chat-item-preview {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.unread-dot {
  min-width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0
}

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border)
}

.chat-topbar-info {
  display: flex;
  align-items: center;
  gap: 12px
}

.chat-topbar-actions {
  display: flex;
  gap: 8px
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 70%
}

.msg-row.out {
  align-self: flex-end;
  flex-direction: row-reverse
}

.msg-row.in {
  align-self: flex-start
}

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 100%;
  word-break: break-word;
  position: relative
}

.bubble.in {
  background: var(--surface);
  border-bottom-left-radius: 4px
}

.bubble.out {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px
}

.bubble-time {
  font-size: 10px;
  opacity: .6;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  justify-content: flex-end
}

.bubble.in .bubble-time {
  color: var(--text3)
}

.bubble img {
  border-radius: var(--radius);
  max-height: 300px;
  cursor: pointer
}

.msg-status {
  font-size: 12px;
  color: rgba(255, 255, 255, .8)
}

.chat-input-area {
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border)
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px
}

.chat-input-box {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  min-height: 40px;
  line-height: 1.5;
  transition: var(--transition)
}

.chat-input-box:focus {
  outline: none;
  border-color: var(--accent)
}

.chat-input-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 4px
}

.chat-input-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition)
}

.chat-input-send:hover {
  background: var(--accent-h);
  transform: scale(1.05)
}

/* ── TEMPLATE PREVIEW (WhatsApp style) ──────────────────── */
.template-phone {
  background: #111;
  border-radius: 32px;
  padding: 12px;
  width: 300px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6)
}

.template-screen {
  background: #0f1117;
  border-radius: 24px;
  overflow: hidden;
  min-height: 480px;
  display: flex;
  flex-direction: column
}

.template-wabg {
  flex: 1;
  background: #0b141a url("data:image/svg+xml,%3Csvg ...%3E%3C/svg%3E");
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end
}

.template-bubble {
  background: #202c33;
  border-radius: 0 10px 10px 10px;
  padding: 10px 14px;
  max-width: 260px;
  font-size: 13px;
  color: #e9edef
}

.template-bubble-header {
  background: #1a2530;
  padding: 0 0 8px;
  border-radius: 0 10px 0 0;
  overflow: hidden;
  margin: -10px -14px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px
}

.template-bubble-body {
  color: #e9edef;
  font-size: 13px;
  line-height: 1.55
}

.template-bubble-footer {
  color: #8696a0;
  font-size: 11px;
  margin-top: 6px
}

.template-btn {
  display: block;
  background: #182229;
  border-top: 1px solid #2a3942;
  padding: 10px;
  color: #00a3af;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition)
}

.template-btn:hover {
  background: #1e2b33
}

/* ── ACTIVITY FEED ──────────────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  position: relative
}

.activity-item:last-child {
  border-bottom: none
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0
}

.activity-body {
  flex: 1;
  min-width: 0
}

.activity-name {
  font-size: 13px;
  font-weight: 600
}

.activity-text {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px
}

.activity-time {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0
}

/* ── TRIGGER CARDS ──────────────────────────────────────── */
.trigger-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: var(--transition)
}

.trigger-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow)
}

.trigger-card.active-trigger {
  border-left: 3px solid var(--green)
}

.trigger-card.inactive-trigger {
  border-left: 3px solid var(--border);
  opacity: .7
}

.trigger-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap
}

.trigger-condition,
.trigger-action {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 12px
}

.trigger-arrow {
  color: var(--text3);
  font-size: 18px
}

/* ── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transform: scale(.96);
  transition: transform .2s
}

.modal-overlay.open .modal {
  transform: scale(1)
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border)
}

.modal-title {
  font-size: 16px;
  font-weight: 700
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px
}

/* ── TABS ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 3px
}

.tab {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition)
}

.tab.active {
  background: var(--surface3);
  color: var(--text)
}

.tab-content>div {
  display: none
}

.tab-content>.active {
  display: block
}

/* ── MEDIA GRID ─────────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px
}

.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition)
}

.media-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px)
}

.media-thumb {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  font-size: 36px;
  color: var(--text3)
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover
}

.media-info {
  padding: 8px 10px
}

.media-name {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.media-meta {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px
}

/* ── LIGHTBOX ───────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .92);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none
}

.lightbox.open {
  display: flex
}

.lightbox img,
.lightbox video {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 64px rgba(0, 0, 0, .8)
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer
}

/* ── TOAST ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .3s ease;
  box-shadow: var(--shadow);
  max-width: 320px
}

.toast.success {
  border-left: 3px solid var(--green)
}

.toast.error {
  border-left: 3px solid var(--red)
}

.toast.info {
  border-left: 3px solid var(--accent)
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0
  }

  to {
    transform: none;
    opacity: 1
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(100%)
  }
}

.toast.hiding {
  animation: fadeOut .3s ease forwards
}

/* ── PROGRESS BAR ───────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-h));
  transition: width .4s ease
}

/* ── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2)
}

.empty-state-icon {
  font-size: 64px;
  opacity: .3;
  margin-bottom: 16px
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px
}

.empty-state p {
  font-size: 13px;
  max-width: 320px;
  margin: 0 auto
}

/* ── CHART CONTAINER ────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 220px
}

/* ── PAGINATION ─────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 16px 0
}

.page-btn {
  min-width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition)
}

.page-btn:hover,
.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent)
}

/* ── SETTINGS ───────────────────────────────────────────── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px
}

.settings-section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px
}

.settings-section-header h3 {
  font-size: 15px;
  font-weight: 600
}

.settings-section-body {
  padding: 20px
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border)
}

.settings-row:last-child {
  border-bottom: none
}

.settings-row-info h4 {
  font-size: 13px;
  font-weight: 600
}

.settings-row-info p {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px
}

/* ── LOG VIEWER ─────────────────────────────────────────── */
.log-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  font-family: monospace;
  font-size: 12px
}

.log-entry.success {
  border-left: 3px solid var(--green)
}

.log-entry.error {
  border-left: 3px solid var(--red)
}

.log-meta {
  display: flex;
  gap: 12px;
  color: var(--text3);
  margin-bottom: 6px;
  font-size: 11px
}

/* ── UTILITY ────────────────────────────────────────────── */
.flex {
  display: flex
}

.flex-col {
  flex-direction: column
}

.items-center {
  align-items: center
}

.justify-between {
  justify-content: space-between
}

.gap-4 {
  gap: 4px
}

.gap-8 {
  gap: 8px
}

.gap-12 {
  gap: 12px
}

.gap-16 {
  gap: 16px
}

.gap-20 {
  gap: 20px
}

.text-muted {
  color: var(--text2)
}

.text-sm {
  font-size: 12px
}

.text-xs {
  font-size: 11px
}

.font-bold {
  font-weight: 700
}

.font-semibold {
  font-weight: 600
}

.mt-4 {
  margin-top: 4px
}

.mt-8 {
  margin-top: 8px
}

.mt-12 {
  margin-top: 12px
}

.mt-16 {
  margin-top: 16px
}

.mt-20 {
  margin-top: 20px
}

.mb-16 {
  margin-bottom: 16px
}

.mb-20 {
  margin-bottom: 20px
}

.w-full {
  width: 100%
}

.text-right {
  text-align: right
}

.text-center {
  text-align: center
}

.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis
}

.accent {
  color: var(--accent)
}

.green {
  color: var(--green)
}

.red {
  color: var(--red)
}

.yellow {
  color: var(--yellow)
}

.rounded {
  border-radius: var(--radius)
}

.rounded-full {
  border-radius: 99px
}

.hidden {
  display: none !important
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0
}

.spin {
  animation: spin 1s linear infinite
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

/* ── HAMBURGER BUTTON (mobile only) ────────────────────── */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0
}

/* ── MOBILE SIDEBAR OVERLAY ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 99;
  backdrop-filter: blur(2px)
}

.sidebar-overlay.open {
  display: block
}

/* ── RESPONSIVE ─────────────────────────────────────────── */

/* Tablet: 1024px */
@media (max-width:1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr)
  }

  .topbar-left h1 {
    font-size: 17px
  }
}

/* Mobile: 768px */
@media (max-width:768px) {

  /* Sidebar becomes a slide-over drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px !important;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.mobile-open {
    transform: translateX(0)
  }

  .sidebar-toggle {
    display: none
  }

  /* Hamburger visible */
  .hamburger {
    display: flex
  }

  /* Main content takes full width */
  .app-wrap {
    flex-direction: column
  }

  .main-content {
    width: 100%;
    overflow-y: auto
  }

  /* Topbar */
  .topbar {
    padding: 12px 16px;
    gap: 8px
  }

  .topbar-left h1 {
    font-size: 16px
  }

  .topbar-left p {
    display: none
  }

  .topbar-right .topbar-btn:nth-child(n+3) {
    display: none
  }

  /* Page body */
  .page-body {
    padding: 12px
  }

  /* All grids collapse to 1 column */
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr !important
  }

  /* Stat cards: 2 columns */
  .grid-4.mb-20 {
    grid-template-columns: repeat(2, 1fr) !important
  }

  /* Chat layout: sidebar hidden by default, toggled via button */
  .chat-layout {
    flex-direction: column;
    height: calc(100vh - 57px)
  }

  .chat-sidebar {
    width: 100% !important;
    height: auto;
    max-height: 45vh;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: none;
  }

  .chat-sidebar.mobile-open {
    display: flex
  }

  .chat-window {
    height: 100%
  }

  .msg-row {
    max-width: 88%
  }

  /* Dashboard two-col section collapses */
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns:1fr 380px"] {
    grid-template-columns: 1fr !important;
  }

  [style*="width:340px"] {
    width: 100% !important
  }

  /* Contacts detail panel: full width below table */
  [style*="display:flex;gap:20px"] {
    flex-direction: column !important
  }

  /* Settings 2-col */
  .grid.grid-2.gap-16 {
    grid-template-columns: 1fr !important
  }

  /* History search form */
  [style*="grid-template-columns:1fr 200px 180px 180px 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Modals */
  .modal {
    max-width: 100% !important;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0
  }

  /* Media grid smaller cells */
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr))
  }

  /* Template grid */
  .grid-auto {
    grid-template-columns: 1fr !important
  }

  /* Trigger flow wrap */
  .trigger-flow {
    flex-direction: column;
    align-items: flex-start
  }

  .trigger-arrow {
    transform: rotate(90deg)
  }

  /* Table: enable horizontal scroll */
  .table-wrap {
    border-radius: var(--radius)
  }

  tbody td,
  thead th {
    padding: 10px 12px;
    font-size: 12px
  }

  /* Toast at bottom center */
  .toast-container {
    right: 12px;
    bottom: 16px;
    left: 12px;
    align-items: stretch
  }

  .toast {
    max-width: 100%
  }
}

/* Small mobile: 480px */
@media (max-width:480px) {
  .grid-4.mb-20 {
    grid-template-columns: 1fr !important
  }

  .stat-value {
    font-size: 22px
  }

  .topbar-left h1 {
    font-size: 15px
  }

  .chat-input-actions .btn-icon-sm:nth-child(n+4) {
    display: none
  }

  .chat-topbar-actions .btn:nth-child(n+3) {
    display: none
  }

  .bubble {
    font-size: 13px
  }
}