:root {
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-input: #ffffff;
  --bg-highlight: #ecfdf5;
  --bg-indigo-soft: #eef2ff;
  --bg-amber-soft: #fffbeb;
  --bg-danger-soft: #fef2f2;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-text: #065f46;
  --brand-teal: #0d9488;
  --brand-navy: #0f172a;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --warning: #d97706;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --info: #0284c7;
  --radius: 12px;
  --sidebar-width: 282px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  font-size: 0.88em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ============================================================================
   APP SHELL & COLLAPSIBLE SIDEBAR LAYOUT (HIDE / UNHIDE)
   ============================================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

.sidebar {
  width: var(--sidebar-width);
  max-width: 86vw;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 90;
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.24s ease;
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.app-shell.sidebar-hidden .sidebar {
  transform: translateX(-100%);
  box-shadow: none;
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100% - var(--sidebar-width));
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.24s cubic-bezier(0.4, 0, 0.2, 1), width 0.24s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  /* Container query support so grids adapt to actual content width! */
  container-type: inline-size;
  container-name: mainarea;
}

.app-shell.sidebar-hidden .main-wrapper {
  margin-left: 0;
  width: 100%;
  max-width: 100%;
}

/* GUEST / AUTHENTICATION MODE: HIDE SIDEBAR & MENU TOGGLE COMPLETELY BEFORE LOGIN */
.app-shell.auth-guest-mode .sidebar {
  display: none !important;
}

.app-shell.auth-guest-mode .sidebar-backdrop {
  display: none !important;
}

.app-shell.auth-guest-mode .sidebar-toggle-btn {
  display: none !important;
}

.app-shell.auth-guest-mode .main-wrapper {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

.category-pills-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
  margin-bottom: 14px;
}

.cat-pill-btn {
  background: #ffffff;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.cat-pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-highlight);
}

.cat-pill-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.22);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 80;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* SIDEBAR HEADER */
.sidebar-header {
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(145deg, #ecfdf5 0%, #f0fdfa 100%);
  border: 1px solid #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 4px;
}

.brand-logo-dark {
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
  border-color: #334155;
}

.brand-logo-svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--brand-navy);
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.brand-wordmark-vou {
  color: #0f172a;
}

.brand-wordmark-trust {
  color: #059669;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.auth-brand-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.auth-brand-lockup img {
  height: 46px;
  width: auto;
  max-width: 100%;
  display: block;
}

.sidebar-close-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.sidebar-close-btn:hover {
  background: var(--bg-highlight);
  color: var(--primary);
  border-color: var(--primary);
}

/* SIDEBAR USER BOX */
.sidebar-user-box {
  margin: 12px 12px 4px;
  padding: 12px;
  background: linear-gradient(135deg, #ecfdf5 0%, #eef2ff 100%);
  border: 1px solid #a7f3d0;
  border-radius: 10px;
}

.sidebar-section-label {
  padding: 12px 16px 6px;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* SIDEBAR NAVIGATION LINKS */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px;
}

.sidebar-link {
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--bg-elevated);
  color: var(--primary);
  border-color: var(--border);
}

.sidebar-link.active {
  background: var(--bg-highlight);
  color: var(--primary-text);
  border-color: #6ee7b7;
  font-weight: 800;
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-text {
  white-space: normal;
  line-height: 1.25;
  overflow-wrap: break-word;
}

/* SIDEBAR FOOTER & ROLE SWITCHER */
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.sidebar-role-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chip-btn {
  width: 100%;
  background: #ffffff;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chip-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-highlight);
}

.chip-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.chip-btn.chip-reset {
  border-color: #fca5a5;
  color: var(--danger);
  background: #fff5f5;
  justify-content: center;
  margin-top: 2px;
}

.chip-btn.chip-reset:hover {
  background: #fee2e2;
}

/* TOPBAR */
.topbar {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-highlight);
  border-color: var(--primary);
  color: var(--primary-text);
}

.topbar-page-title {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 12.5px;
}

.user-pill-info {
  display: flex;
  flex-direction: column;
}

.coin-badge {
  background: var(--bg-amber-soft);
  color: #b45309;
  border: 1px solid #fcd34d;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

/* LAYOUT CONTAINER */
.container {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px 56px;
}

/* CARDS & BANNERS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.hero-banner {
  background: linear-gradient(135deg, #ecfdf5 0%, #eef2ff 100%);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.sub-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  min-width: 0;
}

.info-banner-green {
  background: var(--bg-highlight);
  border: 1px solid #6ee7b7;
  color: #065f46;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
}

.info-banner-indigo {
  background: var(--bg-indigo-soft);
  border: 1px solid #c7d2fe;
  color: #1e1b4b;
  padding: 14px;
  border-radius: 10px;
}

.info-banner-danger {
  background: var(--bg-danger-soft);
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 14px;
  border-radius: 10px;
}

/* ============================================================================
   RESPONSIVE GRIDS (ADAPTIVE TO BOTH CONTAINER WIDTH & VIEWPORT)
   ============================================================================ */
.stat-grid,
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filter-bar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.stat-card,
.metric-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-label,
.metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value,
.metric-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  overflow-wrap: anywhere;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--primary-text);
  font-weight: 600;
  margin-top: 4px;
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-green {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.badge-amber {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.badge-red {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.badge-blue {
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #7dd3fc;
}

.badge-purple {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #a5b4fc;
}

/* FORMS & BUTTONS */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  line-height: 1.3;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 5px rgba(5, 150, 105, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-accent {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 5px rgba(79, 70, 229, 0.2);
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-warning {
  background: #f59e0b;
  color: #1e293b;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: #94a3b8;
  color: var(--text);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* VOUCHER CARD — COMPACT 4-COLUMN MARKETPLACE CATALOG (REFERENCE STYLE) */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@container mainarea (max-width: 960px) {
  .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container mainarea (max-width: 680px) {
  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@container mainarea (max-width: 340px) {
  .catalog-grid {
    grid-template-columns: 1fr;
  }
}

.voucher-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid #d1e3ec;
  background: #ffffff;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease, border-color 0.18s ease;
}

.voucher-card:hover {
  border-color: var(--primary);
  box-shadow: 0 10px 22px -6px rgba(15, 23, 42, 0.13);
  transform: translateY(-2px);
}

.voucher-media-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9.2;
  background: #dff1f7;
  overflow: hidden;
  border-bottom: 1px solid #d5eaf2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voucher-media-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.25s ease;
}

.voucher-card:hover .voucher-media-img {
  transform: scale(1.02);
}

.voucher-body {
  padding: 11px 12px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.voucher-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 9px;
  min-height: 36px;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

.voucher-compact-meta {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.voucher-compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
}

.price-strike {
  text-decoration: line-through;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
}

.price-main {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
}

.voucher-buy-cta {
  margin-top: 4px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 7px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: var(--primary-text);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.15s, color 0.15s;
}

.voucher-card:hover .voucher-buy-cta {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

@media (max-width: 680px) {
  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .voucher-body {
    padding: 9px 10px 10px;
  }
  .voucher-title {
    font-size: 12.5px;
    line-height: 1.32;
    margin-bottom: 7px;
    min-height: 33px;
  }
  .price-main {
    font-size: 14.5px;
  }
}

/* IMAGE UPLOAD & AUTO-COMPRESSION DROPZONE */
.img-upload-dropzone {
  border: 2px dashed #94a3b8;
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.img-upload-dropzone:hover {
  border-color: var(--primary);
  background: #ecfdf5;
}

.img-compress-preview {
  margin-top: 10px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.img-compress-thumb {
  width: 128px;
  height: 74px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f172a;
  flex-shrink: 0;
}

/* VOICE CALL & VIDEO CALL LIVE STUDIO */
.vc-room-box {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 13px;
  margin-top: 12px;
  box-shadow: var(--shadow-sm);
}

.vc-room-box.vc-live-active {
  background: #0f172a;
  border-color: #10b981;
  color: #f8fafc;
}

.vc-screens {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.vc-participant {
  position: relative;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  min-height: 156px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.vc-room-box.vc-live-active .vc-participant {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border-color: #334155;
  color: #f8fafc;
}

.vc-video-element {
  width: 100%;
  height: 135px;
  object-fit: cover;
  border-radius: 8px;
  background: #020617;
  border: 1px solid #334155;
  margin-bottom: 6px;
  display: block;
}

.vc-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #d1fae5;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 6px;
  position: relative;
}

.vc-avatar.voice-pulsing {
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.25), 0 0 0 12px rgba(16, 185, 129, 0.12);
  animation: vcVoiceRing 1.4s infinite ease-in-out;
}

@keyframes vcVoiceRing {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.35), 0 0 0 9px rgba(16, 185, 129, 0.14);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(16, 185, 129, 0.45), 0 0 0 18px rgba(16, 185, 129, 0.18);
  }
}

.vc-audio-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 22px;
  margin: 4px 0 6px;
}

.vc-audio-bar {
  width: 4px;
  background: #10b981;
  border-radius: 2px;
  height: 6px;
  transition: height 0.12s ease;
}

.vc-control-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid #334155;
  border-radius: 10px;
  margin: 10px 0;
}

.vc-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #475569;
  background: #1e293b;
  color: #f8fafc;
  cursor: pointer;
  transition: all 0.15s;
}

.vc-ctrl-btn:hover {
  background: #334155;
}

.vc-ctrl-btn.active-green {
  background: #059669;
  border-color: #10b981;
  color: #ffffff;
}

.vc-ctrl-btn.active-indigo {
  background: #4f46e5;
  border-color: #6366f1;
  color: #ffffff;
}

.vc-ctrl-btn.muted-red {
  background: #991b1b;
  border-color: #ef4444;
  color: #fecaca;
}

.vc-ctrl-btn.end-call {
  background: #dc2626;
  border-color: #f87171;
  color: #ffffff;
}

.vc-speech-bubble {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid #10b981;
  color: #ecfdf5;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.42;
  margin-bottom: 10px;
  text-align: left;
}

.vc-log-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  max-height: 150px;
  overflow-y: auto;
  font-size: 11.5px;
}

.vc-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* STEPPER */
.stepper {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  align-items: center;
  gap: 6px;
  margin: 12px 0;
  padding: 9px 11px;
  background: var(--bg-elevated);
  border-radius: 9px;
  border: 1px solid var(--border);
}

.step-pill {
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.step-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.step-pill.disputed {
  background: #fee2e2;
  border-color: var(--danger);
  color: #991b1b;
}

/* TABLE */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 13px;
  background: #ffffff;
}

th, td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

td code {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  max-width: 600px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 18px;
  box-shadow: var(--shadow-lg);
}

.modal-card-detail {
  max-width: 680px;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-sticky-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.offer-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.offer-actions-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

@media (max-width: 600px) {
  .modal-backdrop {
    padding: 8px;
    align-items: flex-end;
  }
  .modal-card {
    max-height: 90vh;
    border-radius: 16px;
  }
  .offer-card-row {
    flex-direction: column;
    align-items: stretch;
  }
  .offer-actions-wrap {
    margin-left: 0;
    width: 100%;
    padding-top: 8px;
    border-top: 1px dashed #cbd5e1;
  }
}

/* TOAST NOTIFICATION */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  left: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-left: 5px solid var(--primary);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  max-width: 420px;
  width: 100%;
}

.toast.error {
  border-left-color: var(--danger);
  background: #fff5f5;
  color: #991b1b;
}

/* ============================================================================
   CONTAINER QUERIES (Responds to .main-wrapper actual width, with or without sidebar!)
   ============================================================================ */
@container mainarea (max-width: 980px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@container mainarea (max-width: 780px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@container mainarea (max-width: 620px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    grid-template-columns: 1fr;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

@container mainarea (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .vc-screens {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   VIEWPORT MEDIA QUERIES (Fallback & Sidebar Drawer Behavior for All Devices)
   ============================================================================ */
@media (max-width: 1180px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 960px) {
  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .sidebar {
    box-shadow: var(--shadow-lg);
  }
  .app-shell:not(.sidebar-hidden) .sidebar-backdrop {
    display: block;
    opacity: 1;
  }
  .topbar {
    padding: 10px 14px;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 14px 12px 44px;
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    grid-template-columns: 1fr;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .user-pill-info {
    display: none;
  }
  .topbar-page-title {
    font-size: 14px;
  }
  .card {
    padding: 14px;
  }
  .modal-card {
    padding: 16px;
  }
}

@media (max-width: 520px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .vc-screens {
    grid-template-columns: 1fr;
  }
  .topbar-page-title {
    display: none;
  }
  .coin-badge {
    font-size: 11px;
    padding: 3px 8px;
  }
}

/* ============================================================================
   LIVE CHAT & P2P MESSENGER STYLES (RESPONSIVE SPLIT-PANE)
   ============================================================================ */
.chat-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  min-height: 540px;
}

.chat-rooms-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-rooms-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  font-weight: 800;
  font-size: 14px;
}

.chat-room-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 520px;
}

.chat-room-item {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-room-item:hover {
  background: var(--bg-elevated);
}

.chat-room-item.active {
  background: var(--bg-highlight);
  border-left: 4px solid var(--primary);
}

.chat-thread-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-thread-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-messages-box {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  max-height: 410px;
  min-height: 310px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}

.chat-bubble.mine {
  align-self: flex-end;
  background: var(--primary);
  color: #ffffff;
  border-bottom-right-radius: 3px;
}

.chat-bubble.theirs {
  align-self: flex-start;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-bottom-left-radius: 3px;
}

.chat-compose-bar {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: #ffffff;
  display: flex;
  gap: 10px;
  align-items: center;
}

.otp-input-box {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 10px;
  text-align: center;
  font-family: monospace;
  padding: 12px;
}

@container mainarea (max-width: 780px) {
  .chat-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .chat-room-list {
    max-height: 200px;
  }
}

@media (max-width: 960px) {
  .chat-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .chat-room-list {
    max-height: 200px;
  }
  .chat-bubble {
    max-width: 90%;
  }
}
