/* ============================================================
   tx-portal redesign: design system
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Brand: clean blue accent */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #2563eb; /* primary */
  --brand-600: #1d4ed8;
  --brand-700: #1e40af;
  --brand-800: #1e3a8a;

  /* Neutrals */
  --gray-0:   #ffffff;
  --gray-25:  #fbfbfd;
  --gray-50:  #f6f7f9;
  --gray-100: #eceef2;
  --gray-200: #dfe2e8;
  --gray-300: #c5cad3;
  --gray-400: #9aa1ad;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --gray-950: #0a0e16;

  /* Semantic */
  --success-50: #ecfdf5;
  --success-500: #10b981;
  --success-700: #047857;
  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-700: #b45309;
  --danger-50: #fef2f2;
  --danger-500: #ef4444;
  --danger-700: #b91c1c;
  --info-50: #eff6ff;
  --info-500: #3b82f6;
  --info-700: #1d4ed8;

  /* Channel colors */
  --whatsapp: #25d366;
  --instagram: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  --facebook: #1877f2;

  /* Surfaces */
  --bg: var(--gray-50);
  --surface: var(--gray-0);
  --surface-2: var(--gray-25);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --text-subtle: var(--gray-400);

  /* Layout */
  --sidebar-w: 224px;
  --sidebar-w-collapsed: 60px;
  --helper-w: 300px;
  --topbar-h: 48px;
  --radius-sm: 5px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(16,24,40,0.04);
  --shadow-sm: 0 1px 3px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
  --shadow:    0 4px 12px rgba(16,24,40,0.06), 0 2px 4px rgba(16,24,40,0.04);
  --shadow-lg: 0 12px 32px rgba(16,24,40,0.10), 0 4px 8px rgba(16,24,40,0.05);
  --shadow-xl: 0 24px 48px rgba(16,24,40,0.14);

  /* Type */
  --font-sans: "Inter", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Motion */
  --ease: cubic-bezier(.2,.7,.3,1);
  --dur: 180ms;
}

[data-theme="dark"] {
  --bg: #0c1018;
  --surface: #11161f;
  --surface-2: #161c27;
  --border: #232a37;
  --border-strong: #2c3340;
  --text: #e6e8ed;
  --text-muted: #95a0b1;
  --text-subtle: #6c7686;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow:    0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);

  /* Semantic tokens re-tuned for dark: tinted "-50" surfaces + lighter "-700" text
     so badges, banners, deltas, the bulk bar and the 24h window strip stay legible */
  --brand-50:  rgba(37,99,235,.16);
  --brand-600: #60a5fa;
  --brand-700: #93c5fd;
  --success-50: rgba(16,185,129,.16);
  --success-700: #6ee7b7;
  --warning-50: rgba(245,158,11,.16);
  --warning-700: #fcd34d;
  --danger-50: rgba(239,68,68,.16);
  --danger-700: #fca5a5;
  --info-50: rgba(59,130,246,.16);
  --info-700: #93c5fd;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
hr { border: none; border-top: 1px solid var(--border); margin: var(--s-4) 0; }

h1,h2,h3,h4,h5 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 14px; }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 12px; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.sr { position: absolute; width:1px; height:1px; overflow:hidden; clip: rect(0 0 0 0); }

/* ---------- App shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}
.shell.has-helper {
  grid-template-columns: var(--sidebar-w) 1fr var(--helper-w);
}
.shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.shell.collapsed.has-helper { grid-template-columns: var(--sidebar-w-collapsed) 1fr var(--helper-w); }
.shell.has-helper.helper-collapsed { grid-template-columns: var(--sidebar-w) 1fr 0; }
.shell.collapsed.has-helper.helper-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr 0; }
.shell.helper-collapsed .helper { display: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}
/* Sidebar display prefs (set from settings/sidebar-customization) */
.shell.labels-off .nav-item__label, .shell.labels-off .nav-item__badge, .shell.labels-off .sidebar__brand-name { display: none; }
.shell.labels-off .nav-item { justify-content: center; }
.shell.nav-compact .nav-item { padding-top: 7px; padding-bottom: 7px; }
.shell.nav-compact .sidebar__nav { gap: 1px; }
.sidebar__brand-mark { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }
.sidebar__brand-name { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; color: var(--text); }
.shell.collapsed .sidebar__brand-name { display: none; }
/* Collapse/expand chevron beside the logo. */
.sidebar__collapse { margin-left: auto; flex: none; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; background: none; border-radius: 6px; color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s; }
.sidebar__collapse:hover { background: var(--surface-2); color: var(--text); }
.sidebar__collapse svg { transition: transform .18s var(--ease, ease); }
.shell.collapsed .sidebar__brand { flex-direction: row; gap: 2px; padding: 0 4px; justify-content: center; }
.shell.collapsed .sidebar__brand-mark { width: 26px; height: 26px; }
.shell.collapsed .sidebar__collapse { margin-left: 0; width: 18px; }
.shell.collapsed .sidebar__collapse svg { transform: rotate(180deg); }

.sidebar__nav {
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  flex: 1;
}
.sidebar__section-label {
  padding: 10px 10px 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
}
.shell.collapsed .sidebar__section-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--gray-700);
  font-weight: 500;
  font-size: 12.5px;
  position: relative;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
[data-theme="dark"] .nav-item { color: var(--gray-300); }
.nav-item:hover { background: var(--gray-100); color: var(--text); }
[data-theme="dark"] .nav-item:hover { background: var(--surface-2); }
.nav-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
}
[data-theme="dark"] .nav-item.active { background: rgba(37,99,235,.15); color: var(--brand-300); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-500);
}
.nav-item__icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item__label { flex: 1; }
.nav-item__badge {
  background: var(--brand-500);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}
.shell.collapsed .nav-item { justify-content: center; padding: 10px; }
.shell.collapsed .nav-item__label,
.shell.collapsed .nav-item__badge { display: none; }

.sidebar__footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Resource usage pill (sidebar bottom) */
.usage-mini {
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
[data-theme="dark"] .usage-mini { background: var(--surface-2); }
.usage-mini__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}
.usage-mini__bar {
  height: 4px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}
[data-theme="dark"] .usage-mini__bar { background: var(--border); }
.usage-mini__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success-500), #34d399);
  border-radius: 99px;
}
.usage-mini__fill.warn { background: linear-gradient(90deg, var(--warning-500), #fbbf24); }
.usage-mini__fill.danger { background: linear-gradient(90deg, var(--danger-500), #f87171); }
.shell.collapsed .usage-mini { display: none; }

/* ---------- Main column ---------- */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
}
.topbar__crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.topbar__crumbs strong { color: var(--text); font-weight: 600; }
.topbar__crumbs .sep { color: var(--text-subtle); }
.topbar__spacer { flex: 1; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12.5px;
  min-width: 220px;
}
.search-trigger:hover { border-color: var(--border-strong); }
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: all var(--dur);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.notif { position: relative; }
.icon-btn.notif::after {
  content: "";
  position: absolute;
  top: 6px; right: 7px;
  width: 7px; height: 7px;
  background: var(--brand-500);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.workspace-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px 0 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 500;
}
.workspace-switch:hover { background: var(--surface-2); }
.workspace-switch__avatar {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--gray-700), var(--gray-900));
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  color: #fff;
}

.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gray-700), var(--gray-900));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
}

/* ---------- Page area ---------- */
.page {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}
.page__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.page__title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.page__subtitle { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.page__actions { display: flex; gap: 6px; align-items: center; }

/* ---------- Helper right-rail ---------- */
.helper {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.helper__tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  padding: 0 6px;
  align-items: center;
  gap: 2px;
}
.helper__tab {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 5px 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
}
.helper__tab svg { flex: none; }
.helper__tab.active { background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .helper__tab.active { background: rgba(37,99,235,.15); color: var(--brand-300); }
.helper__collapse {
  width: 32px; height: 32px; flex-shrink: 0;
  background: none; border: none; color: var(--text-muted);
  border-radius: 6px; display: grid; place-items: center;
  margin-left: 4px;
}
.helper__collapse:hover { background: var(--surface-2); color: var(--text); }

/* Page-help content */
.page-help { display: flex; flex-direction: column; gap: 12px; }
.page-help h3 { font-size: 16px; margin-bottom: 4px; }
.page-help p { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.55; }
.page-help__section { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.page-help__section + .page-help__section { margin-top: 0; }
.page-help__items { display: flex; flex-direction: column; gap: 8px; }
.page-help__item { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.page-help__item-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-700);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
[data-theme="dark"] .page-help__item-num { background: rgba(37,99,235,.2); color: var(--brand-300); }
.page-help__tip {
  padding: 10px 12px;
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--brand-800);
  display: flex; gap: 8px; align-items: flex-start;
}
[data-theme="dark"] .page-help__tip { background: rgba(37,99,235,.1); border-color: rgba(37,99,235,.3); color: var(--brand-200); }

/* Vertical edge tab to reopen helper when collapsed */
.helper-fab {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  border: 1px solid var(--border);
  border-right: none;
  background: var(--surface);
  border-radius: 8px 0 0 8px;
  padding: 14px 6px 12px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  box-shadow: -2px 0 16px rgba(15,23,42,.06);
  z-index: 50;
  cursor: pointer;
  transition: padding-right var(--dur) var(--ease), color var(--dur) var(--ease);
}
.helper-fab:hover { color: var(--brand-600); padding-right: 10px; }
.helper-fab__text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-transform: uppercase;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
}
.shell.helper-collapsed .helper-fab { display: flex; }
.helper__body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.helper__panel { display: none; flex-direction: column; gap: var(--s-4); }
.helper__panel.active { display: flex; }

.helper-section-title {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

/* AI assist */
.ai-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
[data-theme="dark"] .ai-card { background: var(--surface-2); border-color: var(--border); }
.ai-card__header { display: flex; gap: 6px; align-items: center; font-weight: 600; margin-bottom: 4px; font-size: 12.5px; }
.ai-card__hint { font-size: 11.5px; color: var(--text-muted); margin-bottom: 8px; }
.ai-input {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text);
}
.ai-suggestions { display: flex; flex-direction: column; gap: 4px; }
.ai-chip {
  text-align: left;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  color: var(--text);
}
.ai-chip:hover { border-color: var(--brand-300); background: var(--brand-50); }
.ai-answer { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.ai-answer__q { font-size: 11.5px; color: var(--text-muted); margin-bottom: 6px; }
.ai-answer__q::before { content: "You: "; font-weight: 600; }
.ai-answer__body { font-size: 12.5px; line-height: 1.5; color: var(--text); }
.ai-answer__body::before { content: "AI"; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 16px; margin-right: 6px; border-radius: 5px; background: var(--brand-500); color: #fff; font-size: 9px; font-weight: 700; vertical-align: 1px; }
.ai-answer__dots { display: inline-flex; gap: 3px; }
.ai-answer__dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand-400); animation: aidot 1s infinite ease-in-out; }
.ai-answer__dots i:nth-child(2) { animation-delay: .15s; }
.ai-answer__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes aidot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* Quick actions list */
.quick-list { display: flex; flex-direction: column; gap: 2px; }
.quick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
}
.quick-item:hover { background: var(--surface-2); }
.quick-item__icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--brand-50);
  color: var(--brand-700);
  display: grid; place-items: center;
}
[data-theme="dark"] .quick-item__icon { background: rgba(37,99,235,.15); color: var(--brand-300); }

/* Help / walkthrough */
.walk-step {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  gap: 10px;
}
.walk-step__num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-700);
  font-size: 12px;
  font-weight: 700;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.walk-step.done .walk-step__num { background: var(--success-500); color: #fff; }
.walk-step__title { font-weight: 600; font-size: 13px; }
.walk-step__hint { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ---------- Components ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  background: var(--gray-100);
  color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  white-space: nowrap;
  letter-spacing: -0.005em;
}
[data-theme="dark"] .btn { background: var(--surface-2); }
.btn:hover { background: var(--gray-200); }
[data-theme="dark"] .btn:hover { background: var(--border); }
.btn--primary {
  background: var(--brand-500);
  color: #fff;
  border-color: var(--brand-500);
}
.btn--primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn--subtle { background: var(--surface-2); border-color: var(--border); }
.btn--danger { background: var(--danger-500); color: #fff; border-color: var(--danger-500); }
.btn--danger:hover { background: var(--danger-600, #b91c1c); border-color: var(--danger-600, #b91c1c); color: #fff; }
.btn--sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn--lg { height: 36px; padding: 0 16px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.input, .select {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--dur), box-shadow var(--dur);
  resize: vertical;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px var(--brand-50);
}
[data-theme="dark"] .input:focus, [data-theme="dark"] .select:focus, [data-theme="dark"] .textarea:focus {
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field__label { font-size: 12px; font-weight: 500; color: var(--text); }
.field__hint { font-size: 11.5px; color: var(--text-muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.card--pad-0 { padding: 0; }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.card__title { font-weight: 600; font-size: 13.5px; }
.card__body { padding: 14px; }

/* Stat card */
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat__label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat__value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat__delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 500;
}
.stat__delta--up { background: var(--success-50); color: var(--success-700); }
.stat__delta--down { background: var(--danger-50); color: var(--danger-700); }
.stat__delta--flat { background: var(--gray-100); color: var(--gray-700); }
[data-theme="dark"] .stat__delta--flat { background: var(--surface-2); color: var(--text-muted); }

/* Badge / chip */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-700);
  line-height: 1.5;
}
[data-theme="dark"] .badge { background: var(--surface-2); color: var(--text-muted); }
.badge--success { background: var(--success-50); color: var(--success-700); }
.badge--warning { background: var(--warning-50); color: var(--warning-700); }
.badge--danger  { background: var(--danger-50); color: var(--danger-700); }
.badge--info    { background: var(--info-50); color: var(--info-700); }
.badge--brand   { background: var(--brand-50); color: var(--brand-700); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--success { background: var(--success-500); }
.dot--warning { background: var(--warning-500); }
.dot--danger  { background: var(--danger-500); }
.dot--gray    { background: var(--gray-400); }

/* Avatar */
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(135deg, #818cf8, #6366f1);
}
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 44px; height: 44px; font-size: 13px; }
.avatar--c1 { background: linear-gradient(135deg,#fb923c,#f97316); }
.avatar--c2 { background: linear-gradient(135deg,#34d399,#059669); }
.avatar--c3 { background: linear-gradient(135deg,#60a5fa,#2563eb); }
.avatar--c4 { background: linear-gradient(135deg,#f472b6,#db2777); }
.avatar--c5 { background: linear-gradient(135deg,#a78bfa,#7c3aed); }
.avatar--c6 { background: linear-gradient(135deg,#fbbf24,#d97706); }

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table th {
  text-align: left;
  font-weight: 600;
  padding: 8px 14px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}
.table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table--card { border-radius: 12px; overflow: hidden; }

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  position: relative;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-600); border-bottom-color: var(--brand-500); }

/* Toggle */
.toggle {
  width: 30px; height: 17px;
  background: var(--gray-300);
  border-radius: 99px;
  position: relative;
  cursor: pointer;
  transition: background var(--dur);
  display: inline-block;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur);
  box-shadow: var(--shadow-sm);
}
.toggle.on { background: var(--brand-500); }
.toggle.on::after { transform: translateX(13px); }
[data-theme="dark"] .toggle { background: var(--border-strong); }
[data-theme="dark"] .toggle.on { background: var(--brand-500); }

/* Progress bar */
.progress {
  height: 8px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
}
[data-theme="dark"] .progress { background: var(--surface-2); }
.progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
  border-radius: 99px;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty__icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--brand-50);
  color: var(--brand-600);
  display: grid; place-items: center;
  margin: 0 auto 16px;
}
.empty__title { font-weight: 600; color: var(--text); margin-bottom: 6px; font-size: 15px; }
.empty__hint { font-size: 13px; max-width: 360px; margin: 0 auto 16px; }

/* Banner */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid;
  margin-bottom: 14px;
  font-size: 12.5px;
}
.banner--warning { background: var(--warning-50); border-color: #fde68a; color: var(--warning-700); }
.banner--success { background: var(--success-50); border-color: #a7f3d0; color: var(--success-700); }
.banner--danger  { background: var(--danger-50); border-color: #fecaca; color: var(--danger-700); }
.banner--info    { background: var(--info-50); border-color: #bfdbfe; color: var(--info-700); }
[data-theme="dark"] .banner--warning { border-color: rgba(245,158,11,.38); }
[data-theme="dark"] .banner--success { border-color: rgba(16,185,129,.38); }
[data-theme="dark"] .banner--danger  { border-color: rgba(239,68,68,.38); }
[data-theme="dark"] .banner--info    { border-color: rgba(59,130,246,.38); }
.banner__icon { font-size: 18px; }
.banner__body { flex: 1; font-size: 13px; }
.banner__body strong { font-weight: 600; }

/* Row action icons */
.row-actions { display: inline-flex; align-items: center; gap: 2px; }
.row-action {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid; place-items: center;
  cursor: pointer;
  transition: all var(--dur);
}
.row-action:hover { background: var(--surface-2); color: var(--text); }
.row-action--danger:hover { background: var(--danger-50); color: var(--danger-700); }
.row-action--brand:hover { background: var(--brand-50); color: var(--brand-700); }

/* Channel icon */
.channel {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  color: #fff;
  font-size: 9px;
  flex-shrink: 0;
}
.channel--whatsapp { background: var(--whatsapp); }
.channel--instagram { background: var(--instagram); }
.channel--facebook { background: var(--facebook); }

/* Modal (visual only, no JS open/close in this prototype) */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  display: none;
  align-items: center; justify-content: center;
  /* Above the slide-over drawer (z-index 300) so an open modal covers and blocks
     the drawer. Otherwise the drawer stays clickable under the modal and you can
     trigger a second, stacked modal (e.g. a status-reason dialog over Transfer). */
  z-index: 500;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 10px;
  width: 460px;
  max-width: 95vw;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.modal__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal__title { font-weight: 600; font-size: 14px; }
.modal__body { padding: 16px; }
.modal__footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Command palette */
.cmdk {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  z-index: 200;
  animation: fade-in .15s var(--ease);
}
.cmdk.open { display: flex; }
.cmdk__panel {
  background: var(--surface);
  width: 600px;
  max-width: 92vw;
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.cmdk__input {
  width: 100%;
  padding: 14px 16px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.cmdk__group { padding: 6px 0; border-top: 1px solid var(--border); }
.cmdk__group:first-of-type { border-top: none; }
.cmdk__label { padding: 4px 14px; font-size: 10.5px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.cmdk__item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; font-size: 12.5px;
}
.cmdk__item:hover, .cmdk__item.active { background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .cmdk__item:hover, [data-theme="dark"] .cmdk__item.active { background: rgba(37,99,235,.15); color: var(--brand-300); }
.cmdk__item-icon { width: 24px; height: 24px; border-radius: 5px; background: var(--surface-2); display: grid; place-items: center; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Utility grid layouts */
.row { display: flex; gap: 12px; align-items: center; }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-aside { grid-template-columns: 1fr 320px; }

@media (max-width: 1100px) {
  .grid-4, .grid-5, .grid-6 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-aside { grid-template-columns: 1fr; }
}

.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-6 { gap: var(--s-6); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-2 { margin-bottom: var(--s-2); }
.mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); }
.mb-6 { margin-bottom: var(--s-6); }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-6 { margin-top: var(--s-6); }
.full { width: 100%; }

/* ---------- Sparkline / mini-chart bars ---------- */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 36px;
}
.spark__bar {
  flex: 1;
  background: var(--brand-200);
  border-radius: 2px;
  min-height: 4px;
}
.spark__bar.hi { background: var(--brand-500); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px;
  height: 160px;
  padding-top: 16px;
}
.bar-chart__bar {
  flex: 1;
  background: linear-gradient(180deg, var(--brand-500), var(--brand-300));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: opacity var(--dur);
  position: relative;
}
.bar-chart__bar:hover { opacity: .85; }
.bar-chart__label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
}

.line-area {
  height: 160px;
  background:
    linear-gradient(180deg, var(--brand-100), transparent 70%),
    repeating-linear-gradient(90deg, var(--gray-100) 0 1px, transparent 1px 14%);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}
.line-area svg { width: 100%; height: 100%; }

/* Donut */
.donut {
  width: 130px; height: 130px;
  border-radius: 50%;
  background:
    conic-gradient(
      var(--brand-500) 0 45%,
      #6366f1 45% 70%,
      #34d399 70% 88%,
      var(--gray-200) 88% 100%
    );
  position: relative;
  margin: 0 auto;
}
.donut::after {
  content: "";
  position: absolute;
  inset: 18px;
  background: var(--surface);
  border-radius: 50%;
}
.donut__center {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
  z-index: 1;
}

/* ---------- Inbox-specific ---------- */
.inbox {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}
.inbox--no-helper { grid-template-columns: 320px 1fr; }
.inbox-list {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.inbox-list__header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Filter row: scrollable chips + arrows + a Filter button pinned on the right */
.inbox-filters-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.inbox-list__filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  flex: 1;
  scroll-behavior: smooth;
  scrollbar-width: none;           /* Firefox */
}
.inbox-list__filters::-webkit-scrollbar { display: none; } /* Chrome/Safari */
.inbox-filters-arrow {
  flex: none;
  width: 24px; height: 24px;
  display: none;                    /* shown by JS only when the chips overflow */
  align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.inbox-filters-arrow:hover { color: var(--brand-600); border-color: var(--brand-300); }
.inbox-filters-arrow.show { display: inline-flex; }
.inbox-filters-sticky {
  flex: none;
  border-color: var(--brand-300); color: var(--brand-700);
  display: inline-flex; align-items: center; justify-content: center;
  position: sticky; right: 0;
  width: 28px; height: 26px; padding: 0;
}
.inbox-filters-sticky:hover { background: var(--brand-50); }
/* Fade hint on the right edge until the chips are scrolled fully right */
.inbox-filters-wrap.can-scroll-right .inbox-list__filters {
  -webkit-mask-image: linear-gradient(to right, #000 82%, transparent 100%);
  mask-image: linear-gradient(to right, #000 82%, transparent 100%);
}
.filter-chip {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 11.5px;
  background: var(--surface);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
}
.filter-chip.active { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-700); }
.inbox-list__items { flex: 1; overflow-y: auto; }
.chat-item {
  padding: 9px 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  align-items: center;
  position: relative;
}
.chat-item__check {
  display: none;
  width: 16px; height: 16px;
  margin: 0;
  align-self: center;
  accent-color: var(--brand-500);
  cursor: pointer;
}
/* checkbox only appears in select mode (via More > Select chats) or when checked, never on hover */
.chat-item.checked .chat-item__check { display: inline-block; }
/* reserve a checkbox column only while it is visible, so the meta column doesn't wrap */
.chat-item.checked,
.inbox-list__items.select-mode .chat-item { grid-template-columns: auto auto 1fr auto; }
.inbox-list__items.select-mode .chat-item__check { display: inline-block; }
.chat-item.checked { background: var(--brand-50); }
[data-theme="dark"] .chat-item.checked { background: rgba(37,99,235,.12); }

.chat-item__menu {
  position: absolute;
  top: 50%; right: 8px;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -1px;
  z-index: 2;
}
.chat-item:hover .chat-item__menu { display: flex; }
.chat-item__menu:hover { background: var(--surface-2); color: var(--text); }
/* On hover the ⋯ occupies the top-right corner, so hide the time/unread meta
   underneath it to avoid the overlap. */
.chat-item:hover .chat-item__meta { visibility: hidden; }

.chat-item__badges {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-top: 3px;
}
.chat-item__opened-by {
  font-size: 10.5px;
  color: var(--brand-600);
  margin-top: 2px;
  font-weight: 500;
}

/* 3-dots dropdown menu */
.chat-menu-pop {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 4px;
  z-index: 30;
  display: none;
}
.chat-menu-pop.open { display: block; }
.chat-menu-pop__item {
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
}
.chat-menu-pop__item:hover { background: var(--surface-2); }
.chat-menu-pop__item.danger:hover { background: var(--danger-50); color: var(--danger-700); }
.chat-menu-pop__sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Accordion chat menu (expandable Assign agent / Set priority / Add label) */
.chat-menu-pop--acc { min-width: 226px; max-height: 78vh; overflow-y: auto; }
.chat-menu-pop--acc .cmp-item {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 6px; font: inherit; font-size: 12.5px;
  display: flex; align-items: center; gap: 9px; cursor: pointer; color: var(--text);
}
.chat-menu-pop--acc .cmp-item:hover { background: var(--surface-2); }
.chat-menu-pop--acc .cmp-item.danger { color: var(--danger-600); }
.chat-menu-pop--acc .cmp-item.danger:hover { background: var(--danger-50); }
.cmp-item svg:first-child { flex: none; color: var(--text-muted); }
.cmp-expand .cmp-chev { margin-left: auto; transition: transform .15s var(--ease); color: var(--text-subtle); }
.cmp-group.open .cmp-expand { background: var(--brand-50); color: var(--brand-700); font-weight: 500; }
.cmp-group.open .cmp-expand svg { color: var(--brand-600); }
.cmp-group.open .cmp-chev { transform: rotate(180deg); }
.cmp-sub { padding: 4px 4px 6px; }
.cmp-search {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; margin: 2px 2px 6px;
  color: var(--text-muted);
}
.cmp-search input { border: 0; outline: 0; background: transparent; font: inherit; font-size: 12.5px; width: 100%; color: var(--text); }
.cmp-scroll { max-height: 210px; overflow-y: auto; }
.cmp-dept {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-subtle);
  border: 0; background: transparent; text-align: left; cursor: pointer; font-family: inherit;
}
.cmp-dept:hover { color: var(--brand-700); }
.cmp-dept__all {
  margin-left: auto; font-size: 10px; font-weight: 600; text-transform: none; letter-spacing: 0;
  color: var(--brand-600); background: var(--brand-50); padding: 1px 7px; border-radius: 20px;
  opacity: 0; transition: opacity .12s var(--ease);
}
.cmp-dept:hover .cmp-dept__all { opacity: 1; }
.cmp-opt {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 6px 10px; border-radius: 6px; font: inherit; font-size: 12.5px;
  display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text);
}
.cmp-opt:hover { background: var(--surface-2); }
.cmp-opt.checked { color: var(--brand-700); font-weight: 500; }
.cmp-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
/* Multi-select agent list */
.cmp-cb { width: 15px; height: 15px; flex: none; margin: 0; accent-color: var(--brand-500); cursor: pointer; }
.cmp-opt--check, .cmp-dept--check { cursor: pointer; }
.cmp-dept--check { color: var(--text-subtle); }
.cmp-dept--check span { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.cmp-apply { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.cmp-apply .btn { flex: 1; justify-content: center; }
.cmp-pill {
  margin-left: auto; font-size: 10px; font-weight: 600; padding: 1px 8px; border-radius: 20px;
  background: var(--gray-100); color: var(--gray-600);
}
[data-theme="dark"] .cmp-pill { background: var(--surface-2); color: var(--text-muted); }
.cmp-pill.on { background: var(--success-50); color: var(--success-700); }
/* Muted-chat bell on the list row */
.chat-item__mute { color: var(--text-subtle); display: inline-flex; align-items: center; }

/* Collapsed-sidebar hover tooltip (module name) */
.nav-tip {
  position: fixed; z-index: 400; transform: translateY(-50%);
  background: #111827; color: #fff; padding: 5px 10px; border-radius: 7px;
  font-size: 12px; font-weight: 500; white-space: nowrap; pointer-events: none;
  box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .nav-tip { background: var(--gray-100); color: var(--gray-900); }

/* Topbar notifications */
.notif-wrap { position: relative; display: inline-flex; }
.notif .notif-count {
  position: absolute; top: -3px; right: -3px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 99px; background: var(--danger-500); color: #fff; font-size: 9px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-menu {
  position: absolute; top: calc(100% + 8px); right: 0; width: 300px; z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-xl); display: none; overflow: hidden;
}
.notif-menu.open { display: block; }
.notif-menu__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.notif-menu__read { border: 0; background: transparent; color: var(--brand-600); font: inherit; font-size: 11.5px; cursor: pointer; }
.notif-menu__list { max-height: 320px; overflow-y: auto; }
.notif-item { display: flex; gap: 9px; padding: 10px 12px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.notif-item:hover { background: var(--surface-2); }
.notif-item__dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; margin-top: 5px; flex: none; }
.notif-item.unread { background: var(--brand-50); }
.notif-item.unread .notif-item__dot { background: var(--brand-500); }
[data-theme="dark"] .notif-item.unread { background: rgba(37,99,235,.1); }
.notif-item__title { font-size: 12.5px; }
.notif-item__time { font-size: 11px; color: var(--text-subtle); margin-top: 1px; }
.notif-menu__all { display: block; text-align: center; padding: 9px; font-size: 12px; color: var(--brand-600); text-decoration: none; }
.notif-menu__all:hover { background: var(--surface-2); }

/* Composer @-mention popover */
.mention-pop {
  position: absolute; z-index: 350; max-height: 220px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-xl); padding: 5px;
}
.mention-pop__head { padding: 5px 9px 4px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-subtle); }
.mention-pop__item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 6px 8px; border-radius: 7px;
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
}
.mention-pop__item:hover, .mention-pop__item.active { background: var(--surface-2); }

/* Image thumbnail in the attach preview */
.attach-thumb--img { width: 34px; height: 34px; padding: 0; overflow: hidden; border-radius: 7px; }
.attach-thumb--img img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* In-conversation search bar */
.thread-search {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border); color: var(--text-muted);
}
.thread-search input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; color: var(--text); }
.thread-search button { border: 0; background: transparent; color: var(--text-muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 0 4px; }
.thread-search button:hover { color: var(--text); }

/* Bulk action bar */
.inbox-bulk-bar {
  display: none;
  padding: 8px 12px;
  background: var(--brand-50);
  border-bottom: 1px solid var(--brand-200);
  color: var(--brand-700);
  font-size: 12px;
  font-weight: 500;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.inbox-bulk-bar.show { display: flex; }
.inbox-bulk-bar > span { flex-shrink: 0; white-space: nowrap; }
.inbox-bulk-bar button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.inbox-bulk-bar button:hover { background: var(--gray-100); border-color: var(--border-strong); }
[data-theme="dark"] .inbox-bulk-bar { border-bottom-color: rgba(37,99,235,.3); }
[data-theme="dark"] .inbox-bulk-bar button:hover { background: var(--surface-2); }

/* Channel selector at top */
.channel-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.channel-select:hover { background: var(--surface-2); }

/* Filter modal */
.filter-modal-bg {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.filter-modal-bg.open { display: flex; }
.filter-modal {
  background: var(--surface);
  border-radius: 12px;
  width: 480px; max-width: 95vw;
  max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
}
.filter-modal__header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600;
}
.filter-modal__body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.filter-modal__footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-2);
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--brand-50); }
[data-theme="dark"] .chat-item.active { background: rgba(37,99,235,.12); }
.chat-item__avatar { position: relative; }
.chat-item__channel {
  position: absolute; bottom: -3px; right: -3px;
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  display: grid; place-items: center;
}
.chat-item__channel svg { width: 10px; height: 10px; display: block; }
.chat-item__name { font-weight: 600; font-size: 13.5px; }
.chat-item__preview { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.chat-item__meta { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 4px; align-self: center; flex-shrink: 0; }
.chat-item__time { font-size: 11px; color: var(--text-subtle); white-space: nowrap; }
.chat-item__unread {
  background: var(--brand-500); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 99px;
  padding: 1px 6px;
  min-width: 18px; text-align: center;
}
.chat-item--unread .chat-item__name { font-weight: 700; }
.chat-item--unread .chat-item__preview { color: var(--text); font-weight: 600; }

.thread {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}
.thread__empty {
  position: absolute; inset: 0; z-index: 6;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; background: var(--surface-2); padding: 24px;
}
.thread--closed .thread__empty { display: flex; }
.thread__header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}
.thread__id { flex: 1; min-width: 0; }               /* lets the name/status truncate */
.thread__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread__sub { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread__sub .dot { flex: none; }
.thread__back { display: none; flex: none; }         /* only on mobile */
.thread__messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  display: flex;
  gap: 8px;
  max-width: 70%;
}
.msg--in { align-self: flex-start; }
.msg--out { align-self: flex-end; flex-direction: row-reverse; }
.msg__bubble {
  padding: 9px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow-xs);
}
.msg--out .msg__bubble {
  background: var(--brand-500);
  color: #fff;
  border-color: var(--brand-500);
}
.msg__time { font-size: 11px; color: var(--text-subtle); margin-top: 4px; }
/* Read receipts: gray when delivered, green (WhatsApp) when read; IG shows "Seen" */
.tick { color: var(--text-subtle); font-weight: 700; letter-spacing: -1px; }
.tick--read { color: #25D366; }
.seen { color: var(--brand-500); font-weight: 600; }
.msg__day {
  align-self: center;
  background: var(--gray-100);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
}
[data-theme="dark"] .msg__day { background: var(--surface); }

.composer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
}
.composer__tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.composer__tab { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; background: none; border: none; color: var(--text-muted); }
.composer__tab.active { background: var(--brand-50); color: var(--brand-700); }
.composer__row { display: flex; gap: 8px; align-items: center; }
.composer__textarea {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  resize: none;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font: inherit;
  outline: none;
  color: var(--text);
}
.composer__textarea:focus { border-color: var(--brand-400); background: var(--surface); }
.composer__tools { display: flex; gap: 4px; padding: 4px 0; }
.composer__tool { width: 30px; height: 30px; border: none; background: none; color: var(--text-muted); border-radius: 6px; }
.composer__tool:hover { background: var(--surface-2); color: var(--text); }

/* Customer profile drawer */
.profile-drawer {
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
  position: relative;
}
/* Closeable drawer: when closed, drop the third grid column and hide the panel */
.inbox--drawer-closed { grid-template-columns: 320px 1fr; }
.inbox--drawer-closed.inbox--no-helper { grid-template-columns: 320px 1fr; }
.inbox--drawer-closed .profile-drawer { display: none; }
.profile-drawer__close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
}
.thread__panel-toggle.active { background: var(--brand-50); color: var(--brand-600); }
.profile-drawer__header { text-align: center; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.profile-section { padding: 9px 0; border-bottom: 1px solid var(--border); }
.profile-section:last-child { border-bottom: none; }
.profile-section__label { font-size: 10.5px; color: var(--text-subtle); text-transform: uppercase; font-weight: 600; letter-spacing: .06em; margin-bottom: 4px; }
.profile-section__value { font-size: 12.5px; }

/* Login layout */
.auth-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100vh;
}
.auth-shell__brand {
  background:
    radial-gradient(1000px 600px at 100% 0%, rgba(37,99,235,.08), transparent 60%),
    radial-gradient(800px 500px at 0% 100%, rgba(96,165,250,.08), transparent 60%),
    linear-gradient(160deg, #fafbfc 0%, #f1f5f9 100%);
  color: var(--text);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
/* Subtle dot grid background */
.auth-shell__brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(0,0,0,.05) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  mask-image: radial-gradient(800px 500px at 50% 50%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(800px 500px at 50% 50%, #000 30%, transparent 80%);
}

/* Auth illustration: product preview */
.auth-illust {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  margin: 24px 0;
}
.auth-mock {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.12), 0 8px 16px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  transform: perspective(1200px) rotateY(-4deg) rotateX(2deg);
  transition: transform .4s var(--ease);
}
.auth-mock:hover { transform: perspective(1200px) rotateY(-2deg) rotateX(1deg); }
.auth-mock__header {
  padding: 10px 12px;
  display: flex; gap: 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.auth-mock__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gray-300); }
.auth-mock__dot:nth-child(1) { background: #fb7185; }
.auth-mock__dot:nth-child(2) { background: #fbbf24; }
.auth-mock__dot:nth-child(3) { background: #34d399; }
.auth-mock__title { margin-left: auto; font-size: 11px; color: var(--text-muted); font-weight: 500; }

.auth-mock__chat { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 16px; min-height: 280px; }
.auth-mock__msg { max-width: 78%; padding: 8px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.45; }
.auth-mock__msg--in {
  align-self: flex-start;
  background: var(--surface-2);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.auth-mock__msg--out {
  align-self: flex-end;
  background: var(--brand-500);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.auth-mock__day {
  align-self: center;
  background: var(--gray-100);
  color: var(--text-muted);
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 10px;
  margin: 2px 0;
}
.auth-mock__typing { display: flex; gap: 3px; padding: 10px 12px; background: var(--surface-2); border-radius: 12px; align-self: flex-start; max-width: 50px; }
.auth-mock__typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--gray-400); animation: type 1.4s infinite ease-in-out; }
.auth-mock__typing span:nth-child(2) { animation-delay: 0.15s; }
.auth-mock__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes type {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Floating channel badges around the mock */
.auth-float {
  position: absolute;
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  font-size: 12px;
  font-weight: 500;
  animation: float 4s ease-in-out infinite;
}
.auth-float__icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: grid; place-items: center;
  color: #fff; font-size: 12px;
}
.auth-float--1 { top: 8%; left: -6%; animation-delay: 0s; }
.auth-float--2 { top: 38%; right: -10%; animation-delay: 1.3s; }
.auth-float--3 { bottom: 10%; left: -2%; animation-delay: 2.6s; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Auth brand layout: light theme typography */
.auth-brand-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--brand-600); font-weight: 600; }
.auth-brand-title { font-size: 36px; line-height: 1.1; margin: 10px 0 14px; font-weight: 700; letter-spacing: -0.025em; color: var(--gray-900); }
.auth-brand-title em { font-style: normal; background: linear-gradient(120deg, var(--brand-500), #6366f1 70%, #ec4899); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand-sub { font-size: 15px; color: var(--gray-600); line-height: 1.5; max-width: 380px; font-weight: 400; }
.auth-feature { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 12.5px; color: var(--gray-700); }
.auth-feature__icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--brand-50);
  color: var(--brand-600);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
}
.auth-brand-footer { font-size: 11px; color: var(--gray-500); position: relative; z-index: 1; }
.auth-brand-logo { display: flex; align-items: center; gap: 8px; position: relative; z-index: 1; }
.auth-brand-logo__text { font-weight: 700; font-size: 16px; color: var(--gray-900); letter-spacing: -0.01em; }
.auth-brand-content { position: relative; z-index: 1; }
.auth-shell__form {
  display: grid;
  place-items: center;
  padding: 40px;
  background: var(--surface);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
  opacity: .95;
}
.auth-feature__icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: rgba(255,255,255,.2);
  display: grid; place-items: center;
  flex-shrink: 0;
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-shell__brand { display: none; }
}

/* ---------- Settings sub-nav ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
}
.settings-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  position: sticky;
  top: 16px;
}
.settings-nav__group { padding: 6px 0; border-bottom: 1px solid var(--border); }
.settings-nav__group:last-child { border-bottom: none; }
.settings-nav__label {
  padding: 4px 8px 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-subtle);
}
.settings-nav__item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  font-size: 12.5px; color: var(--gray-700);
}
[data-theme="dark"] .settings-nav__item { color: var(--gray-300); }
.settings-nav__item:hover { background: var(--gray-100); }
[data-theme="dark"] .settings-nav__item:hover { background: var(--surface-2); }
.settings-nav__item.active { background: var(--brand-50); color: var(--brand-700); font-weight: 500; }
[data-theme="dark"] .settings-nav__item.active { background: rgba(37,99,235,.15); color: var(--brand-300); }

@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } .settings-nav { position: static; } }

/* ---------- Index / page list ---------- */
.idx-shell { padding: 40px; max-width: 1100px; margin: 0 auto; }
.idx-hero {
  background: linear-gradient(160deg, #0a0e16 0%, #1a2030 100%);
  color: #fff;
  padding: 48px 40px;
  border-radius: 20px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}
.idx-hero::before {
  content: "";
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(37,99,235,.18) 0%, transparent 70%);
  top: -100px; right: -100px;
  border-radius: 50%;
}
.idx-hero > * { position: relative; z-index: 1; }
.idx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.idx-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all var(--dur) var(--ease);
}
.idx-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--brand-300);
}
.idx-card__icon {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: var(--brand-50);
  color: var(--brand-600);
  display: grid; place-items: center;
  margin-bottom: 4px;
  font-size: 14px;
}
[data-theme="dark"] .idx-card__icon { background: rgba(37,99,235,.15); }
.idx-card__title { font-weight: 600; font-size: 13.5px; }
.idx-card__hint { font-size: 12px; color: var(--text-muted); }
.idx-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-subtle);
  font-weight: 600;
  margin: 24px 0 12px;
}

/* ===== App footer ===== */
.app-footer{
  display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;
  margin-top:auto;padding:14px 24px;border-top:1px solid var(--border);
  background:var(--surface);color:var(--text-muted);font-size:12px;
}
.app-footer__brand{white-space:nowrap}
.app-footer__links{display:flex;align-items:center;gap:18px;flex-wrap:wrap}
.app-footer__links a{color:var(--text-muted);text-decoration:none}
.app-footer__links a:hover{color:var(--brand-600)}
.app-footer__ver{padding:2px 9px;border-radius:20px;background:var(--surface-2);font-size:11px;font-weight:600}

/* ============================================================
   Interaction engine: toasts, menus, forms, tables (interactions.js)
   ============================================================ */

/* Toasts */
.toast-host{
  position:fixed;right:18px;bottom:18px;z-index:700;
  display:flex;flex-direction:column;gap:8px;pointer-events:none;
}
.toast{
  display:flex;align-items:center;gap:9px;
  min-width:220px;max-width:360px;padding:10px 13px;
  background:var(--surface);color:var(--text);
  border:1px solid var(--border);border-left:3px solid var(--gray-400);
  border-radius:9px;box-shadow:var(--shadow-xl);font-size:13px;font-weight:500;
  opacity:0;transform:translateY(8px);transition:opacity .2s var(--ease),transform .2s var(--ease);
  pointer-events:auto;
}
.toast.show{opacity:1;transform:none}
.toast__icon{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;flex:0 0 auto;color:#fff}
.toast--success{border-left-color:var(--success-500)}
.toast--success .toast__icon{background:var(--success-500)}
.toast--error{border-left-color:var(--danger-500)}
.toast--error .toast__icon{background:var(--danger-500)}
.toast--info{border-left-color:var(--info-500)}
.toast--info .toast__icon{background:var(--info-500)}

/* Form grid inside generated modals */
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}

/* Row action menu (popover) */
.tx-menu{
  position:absolute;z-index:600;min-width:150px;padding:5px;
  background:var(--surface);border:1px solid var(--border);border-radius:9px;
  box-shadow:var(--shadow-xl);
}
.tx-menu__item{
  display:block;width:100%;text-align:left;padding:7px 9px;border:0;border-radius:6px;
  background:transparent;color:var(--text);font:inherit;font-size:13px;cursor:pointer;
}
.tx-menu__item{display:flex;align-items:center;gap:7px}
.tx-menu__item:hover{background:var(--surface-2)}
.tx-menu__item--danger{color:var(--danger-600)}
.tx-menu__item--danger:hover{background:var(--danger-50)}
.tx-menu__check{width:14px;height:14px;flex:none;color:var(--brand-600);display:inline-flex;align-items:center;justify-content:center}
.tx-menu__header{padding:6px 9px 4px;font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--text-subtle)}
.tx-menu__input{padding:5px}
.tx-menu__input .input{height:30px;font-size:12.5px}

/* Clickable rows (tables with data-detail) */
.tx-rows-clickable tbody tr{cursor:pointer}
.tx-rows-clickable tbody tr:hover{background:var(--surface-2)}

/* Row actions cell */
.tx-actions{text-align:right;white-space:nowrap}
.tx-actions .icon-btn{opacity:.55}
tr:hover .tx-actions .icon-btn{opacity:1}

/* Sort indicators */
th.tx-sort-asc::after{content:" \2191";color:var(--brand-500)}
th.tx-sort-desc::after{content:" \2193";color:var(--brand-500)}

/* Bulk action bar */
.tx-bulkbar{
  display:flex;align-items:center;gap:10px;padding:9px 14px;
  background:var(--brand-50);border-bottom:1px solid var(--border);
  font-size:13px;font-weight:500;color:var(--brand-700);
}
[data-theme="dark"] .tx-bulkbar{background:rgba(37,99,235,.12)}
.tx-bulkbar span{margin-right:auto}

/* Changelog drawer feed (TX.openChangelog) */
.cl-feed { padding: 16px; display: block; }
.cl-rel { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.cl-rel:last-child { border-bottom: 0; margin-bottom: 0; }
.cl-rel__head { display: flex; align-items: center; gap: 8px; }
.cl-rel__ver { font-weight: 700; font-size: 15px; color: var(--text); }
.cl-rel__date { margin-left: auto; font-size: 11.5px; color: var(--text-subtle); }
.cl-rel__title { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.cl-rel__sec { margin-top: 11px; }
.cl-rel__sec .badge { font-size: 10px; }
.cl-rel__sec .cl-list { margin-top: 7px; }
.cl-viewall { display: block; text-align: center; margin-top: 6px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--brand-600); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.cl-viewall:hover { border-color: var(--brand-300); background: var(--brand-50); }
[data-theme="dark"] .cl-viewall:hover { background: rgba(37,99,235,.12); }
.cl-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.cl-list li { font-size: 12.5px; color: var(--text); padding-left: 16px; position: relative; line-height: 1.5; }
.cl-list li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--brand-400); }

/* Timeline / comments slide-over (TX.openTimeline) */
.tx-drawer-backdrop{position:fixed;inset:0;background:rgba(15,23,42,.45);display:flex;justify-content:flex-end;z-index:300;opacity:0;transition:opacity .2s var(--ease)}
.tx-drawer-backdrop.open{opacity:1}
.tx-drawer{width:460px;max-width:96vw;height:100%;background:var(--surface);display:flex;flex-direction:column;box-shadow:var(--shadow-xl);transform:translateX(100%);transition:transform .22s var(--ease)}
.tx-drawer-backdrop.open .tx-drawer{transform:none}
.tx-drawer__head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;padding:14px 16px;border-bottom:1px solid var(--border)}
.tx-drawer__title{display:flex;align-items:center;gap:8px;font-size:15px;font-weight:600;color:var(--text)}
.tx-drawer__title svg{color:var(--brand-500)}
.tx-drawer__sub{font-size:12px;color:var(--text-muted);margin-top:3px}
/* Compact meta header: Status + properties packed two-per-row so the comment
   feed keeps the maximum vertical space. */
.tx-drawer__meta{padding:10px 16px;border-bottom:1px solid var(--border);display:flex;flex-direction:column;gap:9px}
.tx-drawer__metagrid{display:grid;grid-template-columns:1fr 1fr;gap:8px 12px}
.tx-drawer__field{display:flex;flex-direction:column;gap:3px;min-width:0}
.tx-drawer__field-label{font-size:10.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--text-muted)}
.tx-drawer__field .select,.tx-drawer__status-sel{width:100%;max-width:none;height:33px;padding:5px 26px 5px 10px;font-size:12.5px}
.tx-drawer__metafoot{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.tx-drawer__labelrow{display:flex;align-items:center;gap:8px;min-width:0;flex:1 1 auto}
.tx-drawer__labelrow .tx-drawer__field-label{flex:none}
.tx-drawer__labels{display:flex;flex-wrap:wrap;gap:6px}
.tx-drawer__actions{display:flex;gap:8px;flex:none}
.tx-drawer__feed{flex:1;overflow-y:auto;padding:16px;background:var(--surface-2);display:flex;flex-direction:column;gap:12px}
.tx-tl-empty{margin:auto;text-align:center;color:var(--text-subtle);display:flex;flex-direction:column;align-items:center;gap:4px}
.tx-tl-empty__title{font-size:14px;color:var(--text-muted);font-weight:500;margin-top:6px}
.tx-tl-empty__sub{font-size:12.5px}
.tx-tl-detail{background:var(--surface);border:1px solid var(--border);border-left:3px solid var(--brand-500);border-radius:10px;padding:13px 14px}
.tx-tl-detail__head{display:flex;align-items:center;gap:9px}
.tx-tl-detail__who{display:flex;flex-direction:column;gap:1px;min-width:0}
.tx-tl-detail__who strong{font-size:13px}
.tx-tl-detail__meta{font-size:11.5px;color:var(--text-muted);display:flex;align-items:center;gap:5px;flex-wrap:wrap}
.tx-tl-detail__dot{color:var(--text-subtle)}
.tx-tl-detail__label{font-size:10.5px;text-transform:uppercase;letter-spacing:.06em;color:var(--text-subtle);font-weight:700;margin-top:12px}
.tx-tl-detail__title{font-size:14px;font-weight:600;color:var(--text);line-height:1.35;margin-top:4px}
.tx-tl-detail__body{font-size:13px;color:var(--text);line-height:1.55;margin-top:5px;white-space:pre-wrap}
.tx-tl-divider{display:flex;align-items:center;gap:10px;margin:4px 0 2px;font-size:10.5px;text-transform:uppercase;letter-spacing:.06em;font-weight:700;color:var(--text-subtle)}
.tx-tl-divider::before,.tx-tl-divider::after{content:"";height:1px;background:var(--border);flex:1}
.tpl-btn-x{background:none;border:0;color:inherit;cursor:pointer;font-size:13px;line-height:1;padding:0 0 0 3px;opacity:.6}
.tpl-btn-x:hover{opacity:1}
.tx-tl-detail__grid{display:grid;grid-template-columns:1fr 1fr;gap:6px 14px;margin-top:11px;padding-top:10px;border-top:1px solid var(--border)}
.tx-tl-detail__grid>div{display:flex;flex-direction:column;gap:1px}
.tx-tl-detail__k{font-size:10.5px;text-transform:uppercase;letter-spacing:.05em;color:var(--text-subtle);font-weight:600}
.tx-tl-detail__v{font-size:12.5px;color:var(--text)}
.tx-tl-item{display:flex;gap:9px}
.tx-tl-item__meta{font-size:11.5px;color:var(--text-muted);margin-bottom:2px}
.tx-tl-item__text{font-size:13px;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:9px;padding:8px 11px;line-height:1.45}
.tx-tl-item__text strong{color:var(--brand-600)}
.tx-tl-sys{text-align:center;font-size:11.5px;color:var(--text-subtle);position:relative}
.tx-tl-sys span{background:var(--surface-2);padding:0 8px}
.tx-drawer__cta{display:flex;align-items:center;justify-content:center;gap:7px;padding:11px;border:0;border-top:1px solid var(--border);background:var(--surface);color:var(--warning-700);font:inherit;font-size:13px;font-weight:600;cursor:pointer}
.tx-drawer__cta:hover{background:var(--warning-50)}
.tx-drawer__composer{border-top:1px solid var(--border);padding:12px 14px;background:var(--surface)}
.tx-drawer__inputwrap{position:relative}
.tx-drawer__input{width:100%;border:1px solid var(--brand-300);border-radius:10px;padding:10px 12px;font:inherit;font-size:13px;color:var(--text);background:var(--surface);resize:none;min-height:42px;box-shadow:0 0 0 3px var(--brand-50)}
.tx-drawer__input:focus{outline:none}
.tx-drawer__composer-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:8px}
.tx-mention-pop{position:absolute;left:0;bottom:calc(100% + 6px);width:220px;max-height:180px;overflow-y:auto;background:var(--surface);border:1px solid var(--border);border-radius:9px;box-shadow:var(--shadow-xl);padding:5px;z-index:5}
.tx-mention{display:flex;align-items:center;gap:8px;width:100%;text-align:left;border:0;background:transparent;padding:6px 8px;border-radius:6px;font:inherit;font-size:13px;color:var(--text);cursor:pointer}
.tx-mention:hover{background:var(--surface-2)}
@media (max-width:768px){ .tx-drawer{width:100%} }

/* Table footer / pager */
.tx-tablefoot{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:10px 14px;border-top:1px solid var(--border);
  font-size:12.5px;color:var(--text-muted);
}
.tx-pager{display:flex;align-items:center;gap:8px}
.tx-pager__pos{font-variant-numeric:tabular-nums}

/* ============================================================
   Responsive: tablet and mobile layouts
   ============================================================ */

/* --- Tablet (<=1024px): drop the helper rail, tighten grids --- */
@media (max-width: 1024px) {
  .shell.has-helper,
  .shell.collapsed.has-helper,
  .shell.has-helper.helper-collapsed { grid-template-columns: var(--sidebar-w) 1fr; }
  .shell.collapsed.has-helper,
  .shell.collapsed.has-helper.helper-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .helper { display: none; }
  .grid-4, .grid-5, .grid-6 { grid-template-columns: repeat(2, 1fr); }
  /* inbox: keep list + thread, hide the drawer column (still openable as an overlay) */
  .inbox { grid-template-columns: 300px 1fr; }
  .inbox .profile-drawer {
    position: fixed; top: var(--topbar-h); right: 0; bottom: 0;
    width: 320px; max-width: 88vw; z-index: 70; box-shadow: var(--shadow-xl);
  }
  .inbox--drawer-closed .profile-drawer { display: none; }
}

/* --- Mobile (<=768px): off-canvas sidebar, single-column everything --- */
@media (max-width: 768px) {
  /* Shell collapses to a single content column; sidebar slides in over it. */
  .shell,
  .shell.has-helper,
  .shell.collapsed,
  .shell.collapsed.has-helper,
  .shell.has-helper.helper-collapsed,
  .shell.collapsed.has-helper.helper-collapsed { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 260px; z-index: 80;
    transform: translateX(-100%);
    transition: transform var(--dur, .18s) var(--ease, ease);
  }
  /* Force the full (non-collapsed) sidebar contents even if .collapsed persisted */
  .shell.collapsed .sidebar__section-label,
  .shell.collapsed .nav-item__label,
  .shell.collapsed .nav-item__badge,
  .shell.collapsed .usage-mini { display: revert; }
  .shell.collapsed .sidebar__brand-name { display: inline; }
  .shell.collapsed .sidebar__brand { flex-direction: row; padding: 0 14px; }
  .shell.collapsed .sidebar__collapse svg { transform: none; }
  .shell.collapsed .nav-item { justify-content: flex-start; padding: 9px 12px; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::before {
    content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 79;
  }

  /* Page chrome */
  .page { padding: 14px; }
  .page__header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page__actions { flex-wrap: wrap; }
  .topbar { padding: 0 12px; }
  .topbar__crumbs { font-size: 12px; }

  /* Multi-column helpers collapse to one column */
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6,
  .grid-aside { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  /* Wide tables scroll horizontally inside their card instead of overflowing */
  .card--pad-0 { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 560px; }

  /* Modals and command palette fit the viewport */
  .modal { width: 94vw; }
  .form-grid { gap: 10px; }

  /* Inbox (mobile): show the list full-screen; opening a chat shows the thread
     full-screen over it (WhatsApp-style), and closing returns to the list. */
  .inbox {
    display: block; position: relative;
    height: calc(100vh - var(--topbar-h)); overflow: hidden;
  }
  .inbox-list { height: 100%; border-right: none; }
  .thread {
    position: absolute; inset: 0; z-index: 20; display: none;
  }
  .inbox--chat-open .thread { display: flex; }
  .inbox--chat-open .inbox-list { display: none; }
  /* Profile drawer becomes a full-height slide-over on top of the thread */
  .inbox .profile-drawer { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: 92vw; max-width: 340px; z-index: 70; }

  /* Mobile thread header: show Back, keep it single-row, trim heavy actions */
  .thread__back { display: inline-flex; }
  .thread__header { padding: 8px 12px; }
  .thread__header .btn--sm { display: none; }        /* hide the "Create ticket" text button */
  #threadPinBtn, #threadAssignBtn, #threadPanelToggle, #threadCloseBtn { display: none; }
  .thread__header .row.gap-2 { gap: 2px; }

  .settings-nav__item { padding: 9px 10px; }
}

/* --- Small phones (<=480px): trim further --- */
@media (max-width: 480px) {
  .page { padding: 10px; }
  .page__title { font-size: 18px; }
  .btn { padding: 0 10px; }
  .stat__value { font-size: 19px; }
  .modal__footer { flex-wrap: wrap; }
}
