﻿:root {
  --brand-primary: #4f46e5;
  --brand-primary-dark: #4338ca;
  --brand-accent: #06b6d4;
  --brand-surface: #ffffff;
  --brand-muted: #64748b;
  --brand-border: #e2e8f0;
  --brand-background: #f4f5fb;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(160deg, rgba(79, 70, 229, 0.04), rgba(6, 182, 212, 0.05));
  color: #0f172a;
  min-height: 100vh;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.w-100-sm {
  width: auto;
}

@media (max-width: 575.98px) {
  .w-100-sm {
    width: 100% !important;
  }
}

.stack-sm {
  display: flex;
  gap: 1rem;
}

@media (max-width: 767.98px) {
  .stack-sm {
    flex-direction: column;
    align-items: stretch;
  }
}

.stack-sm__main {
  flex: 1 1 auto;
}

.stack-sm__aside {
  flex: 0 0 auto;
}

@media (max-width: 767.98px) {
  .stack-sm__aside {
    width: 100%;
  }
}

/* ===== Messaging layout ===== */
.chat-hub { border-radius: 1.25rem; background: #fff; border: 1px solid rgba(148,163,184,.25); }
.chat-stats .card { border-radius: 1.1rem; }
.chat-stat__label { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.chat-stat__value { font-weight: 700; }
.chat-stat__meta { font-size: .85rem; }
.chat-empty-icon { width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(79,70,229,.1); color: var(--brand-primary); font-size: 1.75rem; }
.chat-tools .input-group-text { background: #f8fafc; border-color: #e2e8f0; color: #64748b; }
.chat-tools .form-control { border-color: #e2e8f0; }
.chat-filters .btn { border-radius: 999px; }
.chat-filters .btn.active, .chat-filters .btn:hover { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.chat-conversation-list { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1.5rem; }
.chat-conv-card { display: flex; gap: 1rem; align-items: stretch; padding: 1rem 1.1rem; border: 1px solid rgba(148,163,184,.25); border-radius: 1.1rem; text-decoration: none; color: inherit; background: #fff; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.chat-conv-card:hover { transform: translateY(-1px); box-shadow: 0 12px 25px -18px rgba(15,23,42,.4); border-color: rgba(79,70,229,.35); }
.chat-conv-card.is-unread { border-color: rgba(79,70,229,.45); background: rgba(79,70,229,.06); }
.chat-conv-card__media { flex: 0 0 auto; }
.chat-conv-card__body { flex: 1 1 auto; display: flex; flex-direction: column; gap: .65rem; min-width: 0; }
.chat-conv-card__top { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.chat-conv-card__title { font-weight: 600; display: flex; align-items: center; gap: .5rem; color: #1e293b; min-width: 0; }
.chat-conv-card__title span { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv-card__meta { font-size: .85rem; white-space: nowrap; }
.chat-conv-card__preview { font-size: .9rem; line-height: 1.4; color: #475569; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-conv-card__bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: .75rem; }
.chat-conv-card__actions { flex: 0 0 auto; display: flex; gap: .3rem; }
.chat-conv-card__actions .btn-icon { border: 1px solid rgba(148,163,184,.35); background: #fff; width: 36px; height: 36px; }
.chat-conv-card__actions .btn-icon:hover { border-color: rgba(79,70,229,.45); color: var(--brand-primary); background: rgba(79,70,229,.08); }
.chat-badge-unread { display: inline-flex; align-items: center; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: rgba(79,70,229,.15); color: var(--brand-primary); }
.chat-avatar { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #1d4ed8; background: rgba(59,130,246,.15); }
.chat-avatar--lg { width: 56px; height: 56px; font-size: 1.25rem; }
.chat-avatar--group { color: #0f172a; background: rgba(16, 185, 129, .15); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; border: none; background: rgba(148,163,184,0.15); color: #475569; transition: background .2s ease, color .2s ease; }
.btn-icon:hover { background: rgba(79,70,229,.12); color: var(--brand-primary); }
.chat-conv-card__actions .btn-icon { border: 1px solid rgba(148,163,184,.35); background: #fff; width: 36px; height: 36px; }
.chat-conv-card__actions .btn-icon:hover { border-color: rgba(79,70,229,.45); color: var(--brand-primary); background: rgba(79,70,229,.08); }

@media (max-width: 767.98px) {
  .chat-conv-card__title span { max-width: 200px; }
}
.chat-shell {
  border: 1px solid rgba(148,163,184,.25);
  border-radius: 1rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 64vh;
  height: auto;
  box-shadow: 0 22px 45px -32px rgba(15,23,42,.18);
}
.chat-shell__header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(148,163,184,.22);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  justify-content: space-between;
}
.chat-shell__identity { display: flex; flex-direction: column; gap: .2rem; }
.chat-shell__title { margin: 0; font-size: 1.28rem; font-weight: 600; color: #0f172a; }
.chat-shell__meta { font-size: .85rem; color: #64748b; }
.chat-shell__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.chat-shell__actions .btn-icon { width: 38px; height: 38px; border: 1px solid rgba(148,163,184,.3); background: #fff; }
.chat-shell__actions .btn-icon:hover { border-color: rgba(79,70,229,.4); color: var(--brand-primary); background: rgba(79,70,229,.08); }
.chat-shell__body { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.chat-highlights { padding: 1rem 1.5rem 0; display: grid; gap: .75rem; }
.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1.5rem;
  overflow-y: auto;
  background: linear-gradient(180deg, #f9fafb 0%, #f4f6fa 100%);
}
.chat-messages__flow { display: flex; flex-direction: column; gap: 1rem; }
.chat-messages { scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.6) rgba(226,232,240,.6); }
.chat-messages::-webkit-scrollbar { width: 10px; }
.chat-messages::-webkit-scrollbar-track { background: rgba(226,232,240,.6); border-radius: 999px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(148,163,184,.6); border-radius: 999px; border: 2px solid rgba(226,232,240,.6); transition: background .2s ease; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,.75); }
.chat-composer {
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(148,163,184,.22);
  background: #fff;
  display: flex;
  align-items: center;
  gap: .85rem;
  position: sticky;
  position: -webkit-sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
}
.chat-composer .form-control {
  border-radius: .85rem;
  padding: .75rem 1rem;
  border: 1px solid rgba(148,163,184,.4);
  background: #f8fafc;
}
.chat-composer .form-control:focus {
  background: #fff;
  border-color: rgba(79,70,229,.55);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.chat-composer .btn-icon {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(148,163,184,.4);
  background: #fff;
  color: #475569;
}
.chat-composer .btn-icon:hover {
  border-color: rgba(79,70,229,.45);
  color: var(--brand-primary);
  background: rgba(79,70,229,.08);
}
.chat-composer .btn-send {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem 1.2rem;
}
.chat-composer .form-control { border: none; background: transparent; }
.chat-composer .form-control:focus { box-shadow: none; }
.chat-attachment-preview { font-size: .85rem; color: #475569; padding: .35rem .75rem; border: 1px dashed #cbd5e1; border-radius: .65rem; margin-top: .35rem; display: inline-block; background: #f8fafc; }
.chat-pinned { border-radius: 1rem; border: 1px dashed rgba(37,99,235,.35); background: rgba(37,99,235,.06); padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
.chat-top-stack { display: flex; flex-direction: column; gap: .75rem; }
.chat-challenge-strip { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chat-challenge-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .65rem; border-radius: .75rem; background: rgba(14,165,233,.12); color: #0369a1; font-weight: 600; font-size: .8rem; border: 1px solid rgba(14,165,233,.25); text-decoration: none; transition: background .2s ease, color .2s ease, box-shadow .2s ease; }
.chat-challenge-pill:hover { background: rgba(14,165,233,.18); color: #0f172a; text-decoration: none; box-shadow: 0 10px 20px -18px rgba(14,165,233,.8); }
.chat-challenge-pill--active { background: rgba(59,130,246,.18); border-color: rgba(59,130,246,.45); color: #1e3a8a; }
.chat-pinned__icon { font-size: 1.4rem; color: var(--brand-primary); }
.chat-message-author { font-size: .78rem; font-weight: 600; color: #1f2937; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .35rem; }
.system-msg { background: #f8fafc; border: 1px dashed rgba(148,163,184,.55); color: #334155; padding: .75rem 1rem; border-radius: .85rem; max-width: 420px; }
.chat-layout .row { align-items: stretch; }
.chat-sidebar { display:flex; flex-direction:column; gap:1.25rem; }
.chat-insight-card { border-radius:1.1rem; border:1px solid rgba(148,163,184,.25); background:#fff; }
.chat-insight-card .card-body { padding:1.35rem; }
.chat-insight-list { display:grid; gap:.65rem; }
.chat-insight-list li { display:flex; justify-content:space-between; gap:1rem; font-size:.92rem; }
.chat-insight-list .label { color:#64748b; text-transform:uppercase; font-size:.7rem; letter-spacing:.08em; }
.chat-insight-list .value { font-weight:600; color:#1f2937; }
.chat-access { border-radius:1.25rem; border:1px solid rgba(148,163,184,.25); background:#fff; }
.chat-access__about { border-radius:1rem; background:rgba(79,70,229,.05); border:1px solid rgba(79,70,229,.15); padding:1rem 1.25rem; }

.chat-shell {
  height: auto;
}

@media (min-width: 992px) {
  .chat-shell {
    height: calc(100vh - 150px);
    max-height: clamp(640px, 90vh, 840px);
  }
}

@media (max-width: 991px) {
  .chat-shell { min-height: 60vh; }
  .chat-shell__header { padding: 1rem 1.25rem; gap: .75rem 1rem; }
  .chat-shell__actions { width: 100%; justify-content: flex-start; }
  .chat-messages { max-height: 60vh; padding: 1.25rem; }
  .chat-composer { padding: 1rem 1.25rem; gap: .7rem; }
  .chat-composer .form-control { flex: 1 1 auto; min-height: 48px; min-width: 0; }
}

@media (max-width: 575.98px) {
  .chat-shell { border-radius: .85rem; }
  .chat-shell__header { padding: .85rem 1rem; }
  .chat-messages { padding: 1rem; }
  .chat-composer { gap: .6rem; padding: .85rem 1rem 1rem; }
  .chat-composer .btn-send { padding: .6rem 1rem; font-size: .95rem; }
  .chat-conv-card { padding: .9rem 1rem; flex-direction: column; gap: .75rem; }
  .chat-conv-card__top { flex-direction: column; align-items: flex-start; gap: .3rem; }
  .chat-conv-card__meta { font-size: .8rem; display: flex; gap: .5rem; }
  .chat-conv-card__preview { font-size: .85rem; }
  .chat-conv-card__actions { order: -1; width: 100%; justify-content: flex-end; }
  .chat-conv-card__title span { max-width: 100%; }
}
@media (max-width: 380px) {
  .chat-composer { flex-wrap: wrap; }
  .chat-composer .form-control { flex: 1 1 100%; min-width: 100%; }
  .chat-composer .btn-send { width: 100%; justify-content: center; }
}

@supports not (position: sticky) {
  .chat-composer { position: static; }
}

/* Bubble styling (legacy classes modernised) */
.wa-chat { display:flex; flex-direction:column; gap:1rem; }
.wa-header { display:flex; align-items:center; gap:.75rem; padding:.65rem .9rem; border-radius:1rem; background:#fff; border:1px solid rgba(148,163,184,.2); }
.wa-avatar { width:40px; height:40px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; background:rgba(79,70,229,.12); color:var(--brand-primary); font-weight:700; }
.wa-title { font-weight:700; }
.wa-actions { margin-left:auto; display:flex; gap:.35rem; color:#6b7280; }
.wa-pinned { margin-top:.5rem; padding:.75rem 1rem; background:rgba(79,70,229,.06); border:1px dashed rgba(79,70,229,.35); border-radius:1rem; display:flex; align-items:center; gap:.5rem; color:#1e293b; }
.wa-body { flex:1; overflow:auto; border-radius:1rem; background:transparent; display:flex; flex-direction:column; gap:.5rem; }
.wa-input { display:flex; align-items:center; gap:.5rem; padding:.5rem; border-radius:1rem; background:#f8fafc; border:1px solid rgba(148,163,184,.25); }
.wa-input .form-control { border:none; box-shadow:none; }
.wa-input .btn-icon { color:#475569; }
.wa-row { display:flex; }
.wa-row.left { justify-content:flex-start; }
.wa-row.right { justify-content:flex-end; }
.wa-bubble { max-width:min(78%,520px); padding:.7rem .85rem .55rem .85rem; position:relative; font-size:.95rem; line-height:1.45; border-radius:18px; white-space:pre-wrap; word-break:break-word; border:1px solid rgba(148,163,184,.25); background:#fff; box-shadow:0 12px 30px -18px rgba(15,23,42,.45); }
.wa-left { background:#fff; color:#1f2937; }
.wa-right { background:linear-gradient(135deg,#4f46e5,#4338ca); color:#f8fafc; border-color:rgba(79,70,229,.8); box-shadow:0 12px 30px -15px rgba(79,70,229,.55); }
.wa-right::after { content:\"\"; position:absolute; right:-7px; bottom:12px; width:14px; height:14px; background:linear-gradient(135deg,#4f46e5,#4338ca); transform:rotate(45deg); border-bottom-right-radius:6px; box-shadow:2px 2px 0 rgba(79,70,229,.2); }
.wa-left::before  { content:\"\"; position:absolute; left:-7px; bottom:12px; width:14px; height:14px; background:#fff; transform:rotate(45deg); border-bottom-left-radius:6px; box-shadow:-2px 2px 0 rgba(148,163,184,.2); }
.wa-meta { font-size:.75rem; margin-left:.5rem; white-space:nowrap; color:#64748b; display:inline-flex; align-items:center; gap:.25rem; }
.wa-right .wa-meta { color:rgba(255,255,255,.85); }
.wa-left  .wa-meta { color:#94a3b8; }
.wa-day-sep { display:inline-block; margin:8px auto; background:#e2e8f0; color:#334155; padding:.2rem .6rem; border-radius:999px; font-size:.75rem; font-weight:600; border:1px solid rgba(148,163,184,.5); text-transform:uppercase; letter-spacing:.08em; }
.wa-unread-sep { display:inline-block; margin:8px auto; background:#e0e7ff; color:#312e81; padding:.3rem .85rem; border-radius:999px; font-size:.8rem; border:1px solid rgba(79,70,229,.35); font-weight:600; }

a {
  color: var(--brand-primary);
}

a:hover {
  color: var(--brand-primary-dark);
}

main.container,
main .container {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
}

.app-navbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-navbar .navbar-brand {
  font-weight: 600;
  color: #1f2937;
  letter-spacing: -0.01em;
}

.app-navbar .brand-logo {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-block;
  border-radius: 0.75rem;
  object-fit: cover;
}

.app-navbar .brand-logo--dark {
  display: none;
}

html[data-theme='dark'] .app-navbar .brand-logo--light {
  display: none;
}

html[data-theme='dark'] .app-navbar .brand-logo--dark {
  display: inline-block;
}

.navbar-logo {
  width: 32px;
  height: 32px;
  display: inline-block;
}

.navbar-logo--dark {
  display: none;
}

html[data-theme='dark'] .navbar-logo--light {
  display: none;
}

html[data-theme='dark'] .navbar-logo--dark {
  display: inline-block;
}

.app-navbar .brand-text {
  font-size: 1.05rem;
}

.app-navbar .navbar-toggler {
  border: none;
}

.app-navbar .navbar-toggler:focus {
  box-shadow: none;
}

.app-navbar .nav-link {
  padding: 0.75rem 1rem;
  font-weight: 500;
  color: #475569;
  transition: color 0.2s ease, background-color 0.2s ease;
  border-radius: 0.65rem;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus {
  color: #111827;
  background: rgba(79, 70, 229, 0.08);
}

.app-navbar .nav-link.active {
  color: var(--brand-primary);
  background: rgba(79, 70, 229, 0.12);
}

.app-navbar .navbar-cta .btn {
  border-radius: 999px;
}

.app-footer {
  background: rgba(248, 250, 252, 0.92);
  border-top: 1px solid rgba(203, 213, 225, 0.6);
  margin-top: 3rem;
  font-size: 0.85rem;
  color: #475569;
}

.app-footer small {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  margin-bottom: 1rem;
  margin-right: auto;
  border: none;
  background: transparent;
  text-decoration: none;
  color: #475569;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
}

.back-button:hover {
  color: var(--brand-primary);
  transform: translateX(-2px);
}

.back-button:focus {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

.back-button .back-icon {
  display: inline-block;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-header-text {
  max-width: 60ch;
}

.page-title {
  font-size: clamp(1.5rem, 2vw + 1.2rem, 2.25rem);
  font-weight: 600;
  margin: 0;
  color: #0f172a;
}

.page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--brand-muted);
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn {
  border-radius: 0.75rem;
  font-weight: 500;
  padding: 0.65rem 1.2rem;
}

.btn.btn-sm {
  padding: 0.45rem 0.95rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  border: none;
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(135deg, var(--brand-primary-dark), #312e81);
}

.btn-outline-secondary {
  color: #0f172a;
  border-color: rgba(100, 116, 139, 0.4);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.card {
  border: none;
  border-radius: 1rem;
  background: var(--brand-surface);
  box-shadow: 0 20px 40px -25px rgba(15, 23, 42, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 28px 60px -30px rgba(15, 23, 42, 0.28);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  font-weight: 600;
}

.card-footer {
  background: transparent;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.list-group-item {
  border: none;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  padding: 1rem 1.1rem;
}

.list-group-item:last-child {
  border-bottom: none;
}

.list-group-item-action:hover,
.list-group-item-action:focus {
  background: rgba(79, 70, 229, 0.08);
}

.alert {
  border: none;
  border-radius: 0.9rem;
  padding: 1rem 1.15rem;
}

.table {
  color: #0f172a;
}

.table thead th {
  border-bottom: 0;
  font-weight: 600;
  color: #1f2937;
}

.table tbody tr {
  border-color: rgba(148, 163, 184, 0.25);
}

.form-control,
.form-select,
textarea {
  border-radius: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 0.65rem 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus,
textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
}

.badge {
  font-weight: 600;
}

.navbar-text {
  font-size: 0.9rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 2px dashed rgba(148, 163, 184, 0.4);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.7);
}

@media (max-width: 991.98px) {
  .app-navbar .nav-link {
    padding-left: 0.75rem;
  }

  .page-header {
    gap: 1.5rem;
  }

  .page-header-actions {
    width: 100%;
  }
}

@media (max-width: 575.98px) {
  main.container,
  main .container {
    padding-top: 1rem;
  }

  .btn {
    width: 100%;
  }

  .input-group {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .input-group > .form-control,
  .input-group > .form-select {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .input-group > .btn,
  .input-group > .dropdown-toggle {
    width: 100%;
  }

  .list-group-item.d-flex {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem;
  }

  .list-group-item.d-flex > * {
    width: 100%;
  }

  .list-group-item .text-nowrap {
    white-space: normal !important;
  }

  .navbar-brand span {
    font-size: 1rem;
  }

  .filters-dropdown {
    width: 100%;
    min-width: 0;
  }
}
.stat-card {
  background: var(--brand-surface);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05), 0 18px 40px -22px rgba(79, 70, 229, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.15), 0 22px 45px -25px rgba(79, 70, 229, 0.45);
}

.stat-card-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.stat-card-title {
  color: var(--brand-muted);
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.stat-card-value {
  font-size: 1.85rem;
  font-weight: 600;
  margin: 0;
  color: #1f2937;
}
.message-bubble {
  max-width: min(75%, 520px);
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.95rem;
  box-shadow: 0 10px 28px -18px rgba(15, 23, 42, 0.35);
}

.message-bubble-in {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.message-bubble-out {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  color: #fff;
}

.message-author {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.message-text {
  white-space: pre-wrap;
}

.message-meta {
  font-size: 0.75rem;
  margin-top: 0.35rem;
  color: rgba(148, 163, 184, 0.95);
}
.system-msg {
  background: #f8fafc;
  border: 1px dashed rgba(148, 163, 184, 0.55);
}
.conversation-card .card-body {
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.05), rgba(6, 182, 212, 0.03));
}

.conversation-card .card-body::-webkit-scrollbar {
  width: 8px;
}

.conversation-card .card-body::-webkit-scrollbar-thumb {
  background: rgba(79, 70, 229, 0.35);
  border-radius: 4px;
}
.wa-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 170px);
  max-height: 720px;
}
.wa-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .9rem;
  border: 1px solid rgba(148,163,184,.25);
  border-radius: .75rem;
  background: #fff;
}
.wa-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items:center; justify-content:center;
  background:#e5e7eb; color:#374151; font-weight:700;
}
.wa-title { font-weight: 700; }
.wa-actions { margin-left:auto; display:flex; gap:.35rem; color:#6b7280; }
.wa-pinned {
  margin-top:.5rem; padding:.5rem .75rem; background:#f8fafc; border:1px dashed rgba(148,163,184,.55);
  border-radius:.75rem; display:flex; align-items:center; gap:.5rem; color:#334155;
}
.wa-body { flex:1; overflow:auto; border-radius:.75rem; padding:.75rem; background:#0b141a; background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1px); background-size: 24px 24px; }
.wa-input {
  display:flex; align-items:center; gap:.5rem; padding:.5rem; margin-top:.5rem;
  border:1px solid rgba(148,163,184,.35); border-radius:.75rem; background:#fff;
}
.wa-input .form-control { border:none; box-shadow:none; }
.wa-input .btn-icon { color:#6b7280; }
.wa-bubble {
  max-width: min(80%, 540px);
  padding:.55rem .7rem .4rem .7rem;
  position:relative;
  font-size:.95rem;
  line-height:1.35;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow:0 1px 0 rgba(0,0,0,.06);
}
.wa-left {
  background: linear-gradient(180deg, #26333a, #1f2c34);
  color:#e5e7eb;
  border:1px solid #1a242b;
  box-shadow: 0 1px 0 rgba(0,0,0,.25), inset 0 0 0 1px rgba(255,255,255,.02);
}
.wa-right {
  background: linear-gradient(180deg, #0f6f63, #075e54);
  color:#e7fff5;
  border:1px solid #0a4f47;
  box-shadow: 0 1px 0 rgba(0,0,0,.2), inset 0 0 0 1px rgba(255,255,255,.03);
}
.wa-row { display:flex; margin-bottom:.35rem; }
.wa-row.left { justify-content:flex-start; }
.wa-row.right { justify-content:flex-end; }
.wa-meta { font-size:.75rem; color:#64748b; margin-left:.5rem; white-space:nowrap; }
.wa-right .wa-meta{ color: rgba(255,255,255,.85); }
.wa-left .wa-meta{ color: #a7b0b6; }
.system-msg { background:#f8fafc; border:1px dashed rgba(148,163,184,.55); color:#334155; }
.wa-unread-sep { display:inline-block; margin:8px auto; background:#2a2f32; color:#d1d5db; padding:.25rem .75rem; border-radius:999px; font-size:.85rem; }
.wa-day-sep { display:inline-block; margin:8px auto; background:#2a2f32; color:#d1d5db; padding:.2rem .6rem; border-radius:999px; font-size:.8rem; font-weight:600; }

/* Bubble tails */
.wa-right::after {
  content:""; position:absolute; right:-6px; bottom:0; width:12px; height:12px;
  background:#075e54; transform: translateY(-2px) rotate(45deg);
  border-bottom-right-radius: 6px; box-shadow: 1px 1px 0 rgba(0,0,0,.18);
}
.wa-left::before {
  content:""; position:absolute; left:-6px; bottom:0; width:12px; height:12px;
  background:#1f2c34; transform: translateY(-2px) rotate(45deg);
  border-bottom-left-radius: 6px; box-shadow: -1px 1px 0 rgba(0,0,0,.28);
}

/* spacing between stacked rows */
.wa-row + .wa-row{ margin-top:.4rem; }
.auth-layout {
  background: linear-gradient(160deg, rgba(79, 70, 229, 0.08), rgba(6, 182, 212, 0.08));
}
.auth-layout .page-header {
  justify-content: center;
  text-align: center;
}

.auth-layout .page-header-text {
  max-width: 520px;
}
.message-bubble-out .message-author,
.message-bubble-out .message-meta {
  color: rgba(255, 255, 255, 0.85);
}

.chat-entry {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-entry-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.18), rgba(148, 163, 184, 0.08));
  border: 1px solid rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 26px -24px rgba(15, 23, 42, 0.55);
}

.chat-entry-input {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  color: #0f172a;
  font-size: 1rem;
  min-height: 44px;
  max-height: 160px;
  padding: 0;
  resize: none;
  line-height: 1.4;
}

.chat-entry-input:focus {
  outline: none;
}

.chat-entry-input::placeholder {
  color: rgba(71, 85, 105, 0.7);
}

.chat-entry-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chat-entry-btn svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}

.chat-entry-btn:hover,
.chat-entry-btn:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(79, 70, 229, 0.45);
  box-shadow: 0 12px 24px -18px rgba(79, 70, 229, 0.55);
  outline: none;
}

.chat-entry-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: #0f172a;
}

.chat-entry-btn--outline {
  background: rgba(255, 255, 255, 0.85);
}

.chat-entry-btn--send {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.2);
  color: #0f172a;
  box-shadow: 0 16px 30px -22px rgba(15, 23, 42, 0.75);
}

.chat-entry-btn--send svg {
  stroke: none;
  fill: currentColor;
}

.chat-entry-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #64748b;
}

.chat-entry-link {
  font-weight: 600;
  color: var(--brand-primary);
  text-decoration: none;
}

.chat-entry-link:hover {
  text-decoration: underline;
}

.chat-entry-file {
  display: none;
}

@media (max-width: 600px) {
  .chat-entry-bar {
    gap: 0.45rem;
  }

  .chat-entry-btn {
    width: 40px;
    height: 40px;
  }
}

html[data-theme='dark'] .chat-entry-bar {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(71, 85, 105, 0.6);
  box-shadow: 0 18px 32px -24px rgba(2, 6, 23, 0.75);
}

html[data-theme='dark'] .chat-entry-input {
  color: #f8fafc;
}

html[data-theme='dark'] .chat-entry-input::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

html[data-theme='dark'] .chat-entry-btn {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(71, 85, 105, 0.55);
  color: #f8fafc;
}

html[data-theme='dark'] .chat-entry-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: #f8fafc;
}

html[data-theme='dark'] .chat-entry-btn--send {
  background: #f8fafc;
  color: #0f172a;
  border-color: transparent;
}

html[data-theme='dark'] .chat-entry-meta {
  color: rgba(148, 163, 184, 0.8);
}

html[data-theme='dark'] .chat-entry-link {
  color: rgba(129, 140, 248, 0.9);
}
.friend-card {
  display: flex;
  align-items: center;
  gap: 1rem;
}
/* === Theme toggle helpers === */
[data-theme-icon] {
  display: none;
  align-items: center;
}
html:not([data-theme]) [data-theme-icon="dark"],
html[data-theme='light'] [data-theme-icon="dark"] {
  display: inline-flex !important;
}
html[data-theme='dark'] [data-theme-icon="light"] {
  display: inline-flex !important;
}
[data-theme-label] {
  flex: 1;
}

.navbar-cta .dropdown-menu {
  min-width: 15rem;
}

.navbar-cta .dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.navbar-cta .dropdown-menu .dropdown-item i {
  font-size: 1rem;
}

.filters-dropdown {
  min-width: 260px;
}

/* === Dark theme overrides === */
html[data-theme='dark'] {
  color-scheme: dark;
}

html[data-theme='dark'] body {
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.95));
  color: #e2e8f0;
}

html[data-theme='dark'] .app-navbar {
  background: rgba(15, 23, 42, 0.92);
  border-bottom: 1px solid rgba(71, 85, 105, 0.6);
}

html[data-theme='dark'] .app-navbar .navbar-brand,
html[data-theme='dark'] .app-navbar .navbar-brand .brand-text,
html[data-theme='dark'] .app-navbar .navbar-text {
  color: #f1f5f9;
}

html[data-theme='dark'] .app-footer {
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid rgba(71, 85, 105, 0.65);
  color: rgba(226, 232, 240, 0.85);
}

html[data-theme='dark'] .app-footer small {
  color: rgba(226, 232, 240, 0.85);
}

html[data-theme='dark'] .navbar-logo {
  filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.6));
}

html[data-theme='dark'] .app-navbar .nav-link {
  color: #cbd5f5;
}

html[data-theme='dark'] .app-navbar .nav-link:hover,
html[data-theme='dark'] .app-navbar .nav-link:focus {
  color: #f8fafc;
  background: rgba(129, 140, 248, 0.18);
}

html[data-theme='dark'] .app-navbar .nav-link.active {
  color: #f8fafc;
  background: rgba(99, 102, 241, 0.35);
}

html[data-theme='dark'] .navbar-cta .btn-outline-secondary {
  color: #f1f5f9;
  border-color: rgba(148, 163, 184, 0.45);
}

html[data-theme='dark'] .navbar-cta .btn-outline-secondary:hover,
html[data-theme='dark'] .navbar-cta .btn-outline-secondary:focus {
  color: #f8fafc;
  border-color: #818cf8;
}

html[data-theme='dark'] .page-title,
html[data-theme='dark'] .chat-shell__title,
html[data-theme='dark'] .chat-conv-card__title {
  color: #f8fafc;
}

html[data-theme='dark'] .page-subtitle,
html[data-theme='dark'] .chat-shell__meta,
html[data-theme='dark'] .chat-stat__label,
html[data-theme='dark'] .chat-stat__meta,
html[data-theme='dark'] .stat-card-title {
  color: rgba(203, 213, 225, 0.8);
}

html[data-theme='dark'] .chat-stat__value,
html[data-theme='dark'] .stat-card-value {
  color: #f8fafc;
}

html[data-theme='dark'] .chat-avatar--group {
  color: #e2e8f0;
  background: rgba(16, 185, 129, 0.35);
}

html[data-theme='dark'] .btn-outline-secondary {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.55);
  background: transparent;
}

html[data-theme='dark'] .btn-outline-secondary:hover,
html[data-theme='dark'] .btn-outline-secondary:focus {
  background: rgba(129, 140, 248, 0.2);
  color: #f8fafc;
  border-color: rgba(129, 140, 248, 0.65);
}

html[data-theme='dark'] .dropdown-menu {
  background-color: #111827;
  border: 1px solid rgba(71, 85, 105, 0.6);
  box-shadow: 0 20px 50px -28px rgba(15, 23, 42, 0.8);
}

html[data-theme='dark'] .dropdown-item {
  color: #e2e8f0;
}

html[data-theme='dark'] .dropdown-item:hover,
html[data-theme='dark'] .dropdown-item:focus {
  background: rgba(99, 102, 241, 0.28);
  color: #f8fafc;
}

html[data-theme='dark'] .dropdown-divider {
  border-top-color: rgba(71, 85, 105, 0.7);
}

html[data-theme='dark'] .card,
html[data-theme='dark'] .stat-card,
html[data-theme='dark'] .empty-state {
  background: #1e293b;
  color: #e2e8f0;
  box-shadow: 0 20px 45px -25px rgba(2, 6, 23, 0.8);
}

html[data-theme='dark'] .card-header,
html[data-theme='dark'] .card-footer,
html[data-theme='dark'] .list-group-item {
  border-color: rgba(71, 85, 105, 0.6);
  background: transparent;
  color: #e2e8f0;
}
html[data-theme='dark'] .chat-hub,
html[data-theme='dark'] .chat-shell {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(71, 85, 105, 0.65);
}
html[data-theme='dark'] .chat-stat.card {
  background: rgba(20, 29, 47, 0.95);
  border-color: rgba(71, 85, 105, 0.45);
  box-shadow: none;
}
html[data-theme='dark'] .chat-conv-card {
  background: rgba(20, 29, 47, 0.95);
  border-color: rgba(71, 85, 105, 0.55);
  color: #e2e8f0;
}
html[data-theme='dark'] .chat-conv-card:hover {
  box-shadow: 0 12px 25px -20px rgba(15, 23, 42, 0.9);
  border-color: rgba(129, 140, 248, 0.55);
}
html[data-theme='dark'] .chat-conv-card.is-unread {
  background: rgba(79, 70, 229, 0.2);
  border-color: rgba(129, 140, 248, 0.65);
}
html[data-theme='dark'] .chat-conv-card__preview,
html[data-theme='dark'] .chat-conv-card__meta {
  color: #cbd5f5;
}
html[data-theme='dark'] .chat-badge-unread {
  background: rgba(129, 140, 248, 0.25);
  color: #ede9fe;
}
html[data-theme='dark'] .chat-avatar {
  background: rgba(79, 70, 229, 0.35);
  color: #c7d2fe;
}
html[data-theme='dark'] .btn-icon {
  background: rgba(71, 85, 105, 0.45);
  color: #cbd5f5;
}
html[data-theme='dark'] .btn-icon:hover {
  background: rgba(129, 140, 248, 0.35);
  color: #ede9fe;
}
html[data-theme='dark'] .chat-shell__header {
  border-color: rgba(71, 85, 105, 0.55);
}
html[data-theme='dark'] .chat-messages {
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(71, 85, 105, 0.55);
  box-shadow: inset 0 0 0 1px rgba(30, 41, 59, 0.45);
}
html[data-theme='dark'] .chat-messages::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.75);
}
html[data-theme='dark'] .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(71, 85, 105, 0.8);
  border-color: rgba(15, 23, 42, 0.75);
}
html[data-theme='dark'] .chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(129, 140, 248, 0.55);
}
html[data-theme='dark'] .chat-composer {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(71, 85, 105, 0.55);
}
html[data-theme='dark'] .chat-composer .form-control {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(71, 85, 105, 0.6);
  color: #e2e8f0;
}
html[data-theme='dark'] .chat-composer .form-control:focus {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}
html[data-theme='dark'] .chat-attachment-preview {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(99, 102, 241, 0.45);
  color: #cbd5f5;
}
html[data-theme='dark'] .chat-pinned {
  background: rgba(37, 99, 235, 0.22);
  border-color: rgba(129, 140, 248, 0.45);
  color: #e0e7ff;
}
html[data-theme='dark'] .chat-challenge-pill {
  background: rgba(14,165,233,.2);
  border-color: rgba(14,165,233,.4);
  color: #bae6fd;
}
html[data-theme='dark'] .chat-challenge-pill:hover {
  background: rgba(14,165,233,.3);
  color: #e0f2fe;
}
html[data-theme='dark'] .chat-challenge-pill--active {
  background: rgba(59,130,246,.35);
  border-color: rgba(96,165,250,.45);
  color: #e0f2fe;
}
html[data-theme='dark'] .chat-message-author {
  color: #cbd5f5;
}
html[data-theme='dark'] .chat-insight-card,
html[data-theme='dark'] .chat-access {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(71, 85, 105, 0.55);
}
html[data-theme='dark'] .chat-insight-list .value {
  color: #e2e8f0;
}
html[data-theme='dark'] .chat-access__about {
  background: rgba(79,70,229,.2);
  border-color: rgba(129,140,248,.4);
  color: #e0e7ff;
}

html[data-theme='dark'] .list-group-item-action:hover,
html[data-theme='dark'] .list-group-item-action:focus {
  background: rgba(99, 102, 241, 0.22);
}

html[data-theme='dark'] .table {
  color: #e2e8f0;
}

html[data-theme='dark'] .table thead th {
  color: #f8fafc;
}

html[data-theme='dark'] .form-control,
html[data-theme='dark'] .form-select,
html[data-theme='dark'] textarea {
  background-color: #0f172a;
  color: #f1f5f9;
  border-color: rgba(71, 85, 105, 0.6);
}

html[data-theme='dark'] .form-control::placeholder,
html[data-theme='dark'] textarea::placeholder {
  color: rgba(148, 163, 184, 0.65);
}

html[data-theme='dark'] .btn-primary {
  box-shadow: 0 14px 28px -18px rgba(129, 140, 248, 0.65);
}

html[data-theme='dark'] .message-bubble-in,
html[data-theme='dark'] .conversation-card .card-body {
  background: rgba(30, 41, 59, 0.95);
  color: #f1f5f9;
  border-color: rgba(71, 85, 105, 0.6);
}

html[data-theme='dark'] .wa-header,
html[data-theme='dark'] .wa-input {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(71, 85, 105, 0.5);
  color: #e2e8f0;
}

html[data-theme='dark'] .wa-pinned {
  background: rgba(24, 35, 53, 0.8);
  border-color: rgba(99, 102, 241, 0.35);
  color: #e2e8f0;
}

html[data-theme='dark'] .badge {
  color: #0f172a;
}







