:root {
  /* Zalo PC & Enterprise Cloud Palette — Calibrated for WCAG AA (>= 4.5:1) */
  --zalo-rail: #003ea3;
  --zalo-rail-top: #0052cc;
  --zalo-rail-active: rgba(0, 24, 68, 0.3);
  --zalo-rail-hover: rgba(0, 24, 68, 0.16);

  --brand: #005be0;
  --brand-hover: #004bb8;
  --brand-active: #003b94;
  --brand-ink: #004ac2;
  --brand-soft: #ecf3ff;
  --brand-soft-hover: #dbe8ff;
  --brand-border: #b8d3ff;

  --bg-canvas: #f4f5f7;
  --bg-chat: #eef0f3;
  --bg-surface: #ffffff;
  --bg-subtle: #f8f9fb;
  --bg-input-pill: #eaedf0;

  --bubble-self: #e5efff;
  --bubble-self-border: #c7ddff;
  --bubble-in: #ffffff;
  --bubble-in-border: #e1e4ea;

  --text-primary: #0b1b32;
  --text-secondary: #334559;
  --text-muted: #50627a;

  --border: #dfe2e7;
  --border-light: #eaedf0;
  --border-strong: #c5ccd6;

  --success: #047857;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #a14807;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --header-h: 58px;
  --topbar-h: 52px;
  --rail-w: 72px;

  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.07);
  --shadow-md: 0 10px 26px -4px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 20px 44px -10px rgba(0, 0, 0, 0.2);
}

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

::selection {
  background: #dbe8ff;
  color: #0b1b32;
}

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

a {
  text-underline-offset: 2px;
}

button,
input,
select,
option,
textarea {
  font-family: inherit;
  line-height: 1.4;
}

input,
textarea {
  caret-color: var(--brand);
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.zalo-rail button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Custom Slim Scrollbars (Zero ugly OS scrollbars) */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(117, 137, 163, 0.35) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(117, 137, 163, 0.32);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(71, 89, 109, 0.55);
}

.hidden {
  display: none !important;
}

svg.ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

svg.ico-sm {
  width: 15px;
  height: 15px;
}

svg.ico-lg {
  width: 22px;
  height: 22px;
}

/* ==================== LOGIN VIEW (ZALO ID INSPIRED) ==================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(0, 104, 255, 0.14) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(0, 90, 224, 0.12) 0%, transparent 45%),
    linear-gradient(180deg, #e9f2ff 0%, #f4f7fb 52%, #eef3fa 100%);
  padding: 24px;
}

.login-brand-hero {
  text-align: center;
  margin-bottom: 22px;
}

.login-logo-badge {
  width: 66px;
  height: 66px;
  border-radius: 19px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.09);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
  margin-bottom: 12px;
}

.login-logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}

.login-title {
  font-size: 25px;
  font-weight: 800;
  line-height: 1.3;
  color: #0a0e16;
  letter-spacing: -0.4px;
}

.login-sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-card {
  width: 100%;
  max-width: 416px;
  background: var(--bg-surface);
  border: 1px solid rgba(223, 226, 231, 0.9);
  border-radius: 16px;
  padding: 32px 32px 28px;
  box-shadow: 0 16px 38px -8px rgba(0, 0, 0, 0.1);
}

.login-card-heading {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-left {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  display: inline-flex;
  pointer-events: none;
}

.input-icon-wrap .form-input {
  padding-left: 38px;
  height: 42px;
}

.input-icon-right {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
}

.input-icon-right:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.login-footer-note {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ==================== ZALO PC APP SHELL ==================== */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-canvas);
}

/* Far-Left Vertical Zalo Blue Rail */
.zalo-rail {
  width: var(--rail-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--zalo-rail-top) 0%, var(--zalo-rail) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  flex-shrink: 0;
  z-index: 45;
  user-select: none;
  position: relative;
}

.rail-top,
.rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.rail-brand-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 0;
}

.rail-brand-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.24);
}

.rail-brand-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.rail-brand-divider {
  width: 32px;
  height: 1px;
  background: rgba(255, 255, 255, 0.22);
  margin: 1px 0 2px;
}

.rail-profile-wrap {
  position: relative;
  margin-bottom: 6px;
}

.rail-avatar-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: #ffffff;
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  transition: transform 0.15s ease;
}

.rail-avatar-btn:hover {
  transform: scale(1.04);
}

.rail-online-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--zalo-rail-top);
}

.rail-online-dot.offline {
  background: #94a3b8;
}

/* User Profile Popover (Zalo PC Top-Left Menu) */
.profile-popover {
  position: absolute;
  top: 0;
  left: calc(var(--rail-w) + 4px);
  width: 268px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 14px;
  z-index: 90;
  color: var(--text-primary);
}

.popover-user-head {
  padding-bottom: 11px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.popover-user-head-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.popover-brand-mark {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.92;
}

.popover-user-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.popover-user-role {
  display: inline-block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.popover-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.popover-switch-row:hover {
  background: var(--bg-subtle);
}

.popover-menu-btn {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  text-align: left;
}

.popover-menu-btn:hover {
  background: var(--bg-subtle);
}

.popover-menu-btn.danger {
  color: var(--danger);
}

.popover-menu-btn.danger:hover {
  background: var(--danger-bg);
}

/* Rail Navigation Items */
.nav-tabs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0 6px;
}

.nav-tab {
  width: 60px;
  min-height: 54px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: #eef5ff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-tab:hover {
  background: var(--zalo-rail-hover);
  color: #ffffff;
}

.nav-tab.active {
  background: var(--zalo-rail-active);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.nav-tab-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.1px;
  line-height: 1.3;
  text-align: center;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 7px;
  background: #c62828;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1.5px solid var(--zalo-rail-top);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rail-icon-btn {
  width: 44px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #eef5ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.rail-icon-btn:hover {
  background: var(--zalo-rail-hover);
  color: #ffffff;
}

/* ==================== MAIN WORKSPACE COLUMN ==================== */
.shell-content {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Clean Top Workspace Context Header */
.workspace-topbar {
  height: var(--topbar-h);
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

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

.ws-brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 15px;
  color: #0a0e16;
  letter-spacing: -0.3px;
  background: transparent;
  border: none;
  padding: 4px 6px;
  margin-left: -6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ws-brand-pill:hover {
  background: var(--bg-subtle);
}

.ws-brand-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.ws-divider {
  color: var(--border-strong);
  font-weight: 400;
}

.ws-section-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.ws-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.workspace-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.workspace-switcher-label {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.workspace-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background-color: var(--bg-subtle);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2350627a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px 14px;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  padding: 5px 28px 5px 10px;
  cursor: pointer;
  max-width: 280px;
}

.workspace-select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.sse-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.sse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.sse-pill.live {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.sse-pill.live .sse-dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.zalo-count-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  background: var(--brand-soft);
  color: var(--brand-ink);
  border: 1px solid var(--brand-border);
  cursor: pointer;
  transition: background 0.15s;
}

.zalo-count-chip:hover {
  background: var(--brand-soft-hover);
}

.mobile-account-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.mobile-account-btn .rail-online-dot {
  border-color: #ffffff;
  width: 10px;
  height: 10px;
}

/* ==================== WORKSPACE PANES ==================== */
.workspace-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 28px 36px;
}

.page-container {
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tab-pane.inbox-pane {
  padding: 0;
  overflow: hidden;
  display: flex;
}

/* ==================== TAB 1: ZALO PC 3-COLUMN LIVE INBOX ==================== */
.inbox-layout {
  display: grid;
  grid-template-columns: 344px minmax(0, 1fr) 340px;
  width: 100%;
  height: 100%;
  background: transparent;
  position: relative;
}

.inbox-layout.no-crm {
  grid-template-columns: 344px minmax(0, 1fr);
}

/* --- Column 1: Conversation Sidebar --- */
.conv-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #ffffff;
  overflow: hidden;
}

.conv-top-search {
  min-height: var(--header-h);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.zalo-search-box {
  flex: 1;
  height: 34px;
  background: var(--bg-input-pill);
  border: 1px solid transparent;
  border-radius: 17px;
  display: flex;
  align-items: center;
  padding: 0 11px;
  gap: 7px;
  transition: background 0.15s, border-color 0.15s;
}

.zalo-search-box:focus-within {
  background: #ffffff;
  border-color: var(--brand);
}

.zalo-search-box svg {
  color: var(--text-muted);
}

.zalo-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 0;
}

.zalo-search-input:focus {
  outline: none;
}

.zalo-search-input::placeholder {
  color: var(--text-muted);
}

.icon-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.icon-action-btn:hover {
  background: var(--bg-input-pill);
  color: var(--text-primary);
}

.icon-action-btn.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.mobile-back-btn,
.crm-drawer-close-btn {
  display: none;
}

.crm-drawer-backdrop {
  display: none;
}

.filter-dot-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
}

/* Collapsible Advanced Filter Drawer */
.conv-filter-drawer {
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conv-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

/* Zalo-Style Underline Tabs Row (Zero horizontal scrollbar) */
.conv-tabs-bar {
  min-height: 38px;
  padding: 2px 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex-shrink: 0;
}

.filter-pill {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  padding: 8px 8px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}

.filter-pill:hover {
  color: var(--brand-ink);
}

.filter-pill.active {
  color: var(--brand-ink);
  border-bottom-color: var(--brand);
}

/* Conversation List Items */
.conv-list {
  flex: 1;
  overflow-y: auto;
}

.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid #f2f4f7;
  cursor: pointer;
  transition: background 0.12s ease;
  position: relative;
}

.conv-item:hover {
  background: #f3f5f8;
}

.conv-item.active {
  background: var(--brand-soft);
}

.conv-item.unread .conv-name {
  font-weight: 700;
  color: var(--text-primary);
}

.conv-item.unread .conv-preview {
  font-weight: 600;
  color: var(--text-primary);
}

/* Avatars with Zalo Pastel Tones */
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
  font-size: 14.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid rgba(8, 28, 54, 0.06);
}

.avatar.tone-0 { background: #e0f2fe; color: #0369a1; }
.avatar.tone-1 { background: #dcfce7; color: #15803d; }
.avatar.tone-2 { background: #dbe8ff; color: var(--brand-ink); }
.avatar.tone-3 { background: #fffbeb; color: var(--warning); }
.avatar.tone-4 { background: #eaedf0; color: var(--text-secondary); }
.avatar.tone-5 { background: #ccfbf1; color: #0f766e; }

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.avatar-md {
  width: 40px;
  height: 40px;
  font-size: 13.5px;
}

.avatar-lg {
  width: 58px;
  height: 58px;
  font-size: 18px;
}

.conv-body {
  flex: 1;
  min-width: 0;
}

.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.conv-name-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.conv-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.conv-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.conv-preview {
  font-size: 12.8px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-dot {
  background: #c62828;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  min-width: 19px;
  height: 19px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.conv-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.mini-tag {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f4f8;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Empty List State */
.conv-empty-box {
  padding: 42px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-circle-ico {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.empty-brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
}

/* --- Column 2: Chat Stream & Welcome Canvas --- */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-chat);
  overflow: hidden;
  min-width: 0;
}

.chat-empty {
  flex: 1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
  text-align: center;
}

.welcome-hero-icon {
  width: 82px;
  height: 82px;
  border-radius: 23px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.09);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.09);
}

.welcome-hero-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  display: block;
}

.welcome-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.welcome-desc {
  max-width: 480px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 26px;
}

.welcome-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 196px));
  gap: 12px;
  max-width: 620px;
}

.welcome-action-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.welcome-action-card:hover {
  background: #ffffff;
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.welcome-action-card .w-ico {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 9px;
}

.welcome-action-card .w-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.welcome-action-card .w-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 2px;
}

.chat-active-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Chat Header (Exact 58px aligned with Column 1 & Column 3) */
.chat-header {
  min-height: var(--header-h);
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.chat-title-main {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-title-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#chatHeaderMeta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.typing-indicator {
  color: var(--brand-ink);
  font-weight: 600;
  font-size: 12px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chat-search-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Message Stream */
.msg-stream {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-date-sep {
  align-self: center;
  background: #dfe5ee;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  padding: 3px 12px;
  border-radius: 999px;
  margin: 6px 0;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 76%;
  align-self: flex-start;
  position: relative;
}

.msg-row.self {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-bubble {
  background: var(--bubble-in);
  border: 1px solid var(--bubble-in-border);
  border-radius: 4px 12px 12px 12px;
  padding: 10px 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  min-width: 88px;
  max-width: calc(100% - 42px);
  position: relative;
}

.msg-row.self .msg-bubble {
  background: var(--bubble-self);
  border-color: var(--bubble-self-border);
  border-radius: 12px 4px 12px 12px;
  max-width: 100%;
}

.msg-bubble.undone {
  background: #f8f9fb !important;
  border-style: dashed;
  color: var(--text-muted);
  font-style: italic;
}

.msg-sender-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.msg-quote-box {
  border: 1px solid var(--brand-border);
  background: rgba(0, 91, 224, 0.06);
  padding: 7px 10px;
  border-radius: 7px;
  margin-bottom: 7px;
  font-size: 12px;
  line-height: 1.45;
}

.msg-quote-author {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 12px;
}

.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.48;
  color: var(--text-primary);
}

.msg-attachments {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 5px;
}

.msg-img {
  max-width: 300px;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  object-fit: cover;
}

.msg-sticker {
  width: 116px;
  height: 116px;
  object-fit: contain;
}

.msg-video {
  max-width: 320px;
  border-radius: 8px;
}

.msg-file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f8f9fb;
  border: 1px solid var(--border);
  padding: 9px 11px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
}

.msg-file-card:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
}

.msg-status-tag {
  font-weight: 600;
  color: var(--brand-ink);
}

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.reaction-pill {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
}

.msg-actions-bar {
  display: none;
  align-items: center;
  gap: 2px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 5px;
  box-shadow: var(--shadow-sm);
  align-self: center;
  flex-shrink: 0;
}

.msg-row:hover .msg-actions-bar,
.msg-row:focus-within .msg-actions-bar,
.msg-row.touch-actions-open .msg-actions-bar {
  display: inline-flex;
}

.msg-act-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  padding: 4px 7px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.msg-act-btn:hover {
  background: var(--bg-subtle);
  color: var(--brand-ink);
}

/* --- Zalo PC Two-Tier Composer --- */
.composer-wrap {
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  transition: box-shadow 0.15s;
}

.composer-wrap:focus-within {
  box-shadow: inset 0 2px 0 0 var(--brand);
}

.composer-quote-bar,
.composer-files-bar {
  padding: 7px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.pending-files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pending-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: var(--brand-ink);
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.composer-toolbar {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-light);
  gap: 6px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar-left::-webkit-scrollbar {
  display: none;
}

.tool-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.tool-btn:hover {
  background: var(--bg-input-pill);
  color: var(--brand-ink);
}

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px 12px;
}

.composer-textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 4px 2px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  resize: none;
  min-height: 42px;
  max-height: 130px;
  line-height: 1.45;
}

.composer-textarea:focus {
  outline: none;
}

.composer-textarea::placeholder {
  color: var(--text-muted);
}

.btn-send-zalo {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--brand);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.btn-send-zalo:hover:not(:disabled) {
  background: var(--brand-hover);
}

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

.quick-popup {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  max-height: 250px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 35;
}

.quick-popup-item {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.quick-popup-item:hover {
  background: var(--brand-soft);
}

/* --- Column 3: Zalo Right Info Drawer ("Thông tin hội thoại") --- */
.crm-sidebar {
  border-left: 1px solid var(--border);
  background: #ffffff;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crm-drawer-header {
  min-height: var(--header-h);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

.crm-drawer-scroll {
  flex: 1;
  overflow-y: auto;
}

.crm-hero-profile {
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-bottom: 6px solid var(--bg-chat);
}

.crm-hero-name {
  margin-top: 9px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.crm-hero-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.crm-section {
  padding: 14px 16px;
  border-bottom: 6px solid var(--bg-chat);
}

.crm-section:last-child {
  border-bottom: none;
}

.crm-section-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==================== MANAGEMENT PAGES & CARDS (TABS 2-6) ==================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

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

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

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

.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 43px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-actions-bottom {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* KPI Metric Cards */
.stat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--brand-soft); color: var(--brand-ink); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.sky { background: #e0f2fe; color: #0369a1; }
.stat-icon.amber { background: var(--warning-bg); color: var(--warning); }

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

.stat-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
  line-height: 1.3;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 12px;
}

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  font-family: inherit;
  color: var(--text-primary);
  background: #ffffff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input,
.form-select {
  height: 36px;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2350627a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px 14px;
  padding-right: 30px;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 91, 224, 0.12);
}

.form-input-sm,
.form-select-sm {
  height: 32px;
  padding: 4px 9px;
  font-size: 12px;
  line-height: 1.35;
  border-radius: 6px;
}

.form-select-sm {
  padding-right: 26px;
  background-position: right 7px center;
}

.form-textarea.form-input-sm {
  height: auto;
  padding: 6px 9px;
  line-height: 1.45;
}

.copy-field-row {
  display: flex;
  gap: 6px;
}

.copy-field-row .form-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.2px;
  background: var(--bg-subtle);
}

/* Color Picker Group */
.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.color-picker-wrap input[type="color"] {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

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

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
}

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

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

.btn-soft {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-color: var(--brand-border);
}

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

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

.btn-outline:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-neutral {
  background: #f1f4f8;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-brand {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border: 1px solid var(--brand-border);
}

/* Tables (Clean Divider Hierarchy inside Cards — Zero Nested Card Border) */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: none;
  border-radius: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  line-height: 1.45;
  vertical-align: middle;
}

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

tbody tr:hover {
  background: #fafbfc;
}

th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  border-top: 1px solid var(--border-light);
}

code {
  background: #f1f4f8;
  color: #0f3d8a;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ==================== MODALS & TOASTS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 27, 50, 0.52);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 16px;
}

.lightbox-backdrop {
  background: rgba(11, 27, 50, 0.9);
}

.modal-box {
  background: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  text-align: left;
}

.modal-brand-ico {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.qr-frame {
  width: 244px;
  height: 244px;
  margin: 14px auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.qr-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  margin-top: 12px;
}

.sticker-cell {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}

.sticker-cell:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.sticker-cell img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 220;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #081c36;
  color: #ffffff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  max-width: 380px;
}

.toast.error {
  background: #b91c1c;
}

.toast.success {
  background: #047857;
}

/* ==================== ONE-TIME ZALO PC HISTORY SYNC MODAL ==================== */
.hs-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 14px;
}

.hs-banner svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--success);
}

.hs-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.hs-step-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.45;
}

.hs-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.hs-launcher-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.hs-launcher-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.hs-launcher-btn:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.hs-launcher-btn.recommended {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.hs-launcher-btn.recommended:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #ffffff;
}

.hs-mac-guide {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 13px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 14px;
}

.hs-mac-guide svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--brand-ink);
}

.hs-mac-guide code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 600;
}

.hs-progress-card {
  padding: 12px 14px;
  border-radius: 10px;
  border: none;
  background: var(--bg-subtle);
  margin-bottom: 14px;
}

.hs-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  margin-bottom: 8px;
}

.hs-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.hs-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #10b981);
  transition: width 0.3s ease;
}

.hs-advanced-box {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  margin-bottom: 12px;
}

.hs-advanced-box summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

/* ==================== MULTI-DEVICE RESPONSIVE & TOUCH ADAPTATION ==================== */

/* Compact Desktop (1280px–1420px): 3-Column Coaxial Fit */
@media (max-width: 1420px) {
  .inbox-layout {
    grid-template-columns: 312px minmax(0, 1fr) 308px;
  }
  .inbox-layout.no-crm {
    grid-template-columns: 312px minmax(0, 1fr);
  }
  .conv-tabs-bar {
    padding: 2px 8px 0;
    gap: 0;
  }
  .filter-pill {
    padding: 8px 6px;
    font-size: 12px;
  }
  .composer-toolbar .tool-btn {
    padding: 6px 8px;
  }
  .composer-toolbar .tool-btn span {
    display: none;
  }
}

/* Tablet Landscape & Compact Laptops (<= 1180px): 2-Column Master-Detail + Slide-Over CRM 360 Drawer */
@media (max-width: 1180px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .inbox-layout,
  .inbox-layout.no-crm {
    grid-template-columns: 296px minmax(0, 1fr);
  }
  .crm-sidebar {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(368px, 92vw);
    height: auto;
    z-index: 96;
    box-shadow: var(--shadow-lg);
  }
  .crm-drawer-header {
    justify-content: space-between;
    padding: 8px 16px;
  }
  .crm-drawer-close-btn {
    display: inline-flex;
  }
  .crm-drawer-backdrop {
    display: block;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 27, 50, 0.36);
    z-index: 94;
  }
}

/* Tablet Portrait (<= 960px): Stacked Management Grids */
@media (max-width: 960px) {
  .inbox-layout,
  .inbox-layout.no-crm {
    grid-template-columns: 272px minmax(0, 1fr);
  }
  .grid-2,
  .grid-3,
  .welcome-quick-grid {
    grid-template-columns: 1fr;
  }
  .workspace-switcher-label,
  #sseStatusText {
    display: none;
  }
  .sse-pill {
    padding: 7px;
  }
  .workspace-select {
    max-width: 190px;
  }
  .tab-pane:not(.inbox-pane) {
    padding: 18px 18px 28px;
  }
}

/* Mobile Web (320px–767px): Bottom Navigation Bar + Single-Column Master-Detail Inbox */
@media (max-width: 767px) {
  .login-wrap {
    padding: 16px;
    min-height: 100dvh;
  }
  .login-card {
    padding: 24px 20px 22px;
  }

  .app-shell {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }
  .shell-content {
    order: 1;
    flex: 1;
    height: auto;
    min-height: 0;
  }

  /* Bottom Navigation Rail (Thumbs-First, >= 48px Touch Targets, Safe-Area Inset) */
  .zalo-rail {
    order: 2;
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: center;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.16);
  }
  .rail-brand-btn,
  .rail-brand-divider,
  .rail-avatar-btn,
  .rail-bottom {
    display: none;
  }
  .rail-top {
    flex-direction: row;
    gap: 0;
    width: 100%;
  }
  .rail-profile-wrap {
    margin: 0;
  }
  .profile-popover {
    position: fixed;
    top: 54px;
    right: 10px;
    left: auto;
    width: min(284px, calc(100vw - 20px));
    z-index: 135;
  }
  .nav-tabs {
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
    padding: 0;
    width: 100%;
  }
  .nav-tab {
    flex: 1;
    width: auto;
    min-width: 0;
    min-height: 50px;
    padding: 4px 2px;
    border-radius: 9px;
  }
  .nav-tab svg.ico-lg {
    width: 20px;
    height: 20px;
  }
  .nav-badge {
    top: 2px;
    right: calc(50% - 20px);
  }

  /* Compact Mobile Workspace Header */
  .workspace-topbar {
    height: auto;
    min-height: 48px;
    padding: 6px 12px;
    gap: 8px;
  }
  .ws-brand-pill span,
  .ws-divider,
  .ws-section-name,
  .workspace-switcher-label,
  #sseStatusText {
    display: none;
  }
  .ws-topbar-right {
    gap: 6px;
  }
  .workspace-switcher {
    gap: 6px;
  }
  .workspace-select {
    max-width: 138px;
    font-size: 13px;
    padding: 5px 26px 5px 8px;
  }
  #btnNewTenant span {
    display: none;
  }
  .zalo-count-chip {
    padding: 4px 8px;
  }
  .sse-pill {
    padding: 7px;
  }
  .mobile-account-btn {
    display: inline-flex;
  }

  /* Master-Detail Mobile Inbox Flow */
  .inbox-layout,
  .inbox-layout.no-crm {
    grid-template-columns: 1fr;
  }
  .conv-sidebar {
    border-right: none;
    display: flex;
  }
  .chat-panel {
    display: none;
  }
  .inbox-layout.mobile-chat-open .conv-sidebar {
    display: none;
  }
  .inbox-layout.mobile-chat-open .chat-panel {
    display: flex;
  }
  .mobile-back-btn {
    display: inline-flex;
    margin-left: -6px;
  }

  /* Full-Screen Active Chat Focus on Mobile (Zalo Mobile Ergonomics) */
  .app-shell.mobile-chat-focus .workspace-topbar,
  .app-shell.mobile-chat-focus .zalo-rail {
    display: none;
  }
  .app-shell.mobile-chat-focus .chat-header {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }
  .app-shell.mobile-chat-focus .composer-input-row {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .app-shell.mobile-chat-focus .crm-sidebar,
  .app-shell.mobile-chat-focus .crm-drawer-backdrop {
    top: 0;
  }

  .crm-sidebar {
    top: 48px;
    width: min(360px, 94vw);
  }
  .crm-drawer-backdrop {
    top: 48px;
  }

  /* Touch Target & Anti-Zoom Sizing */
  .icon-action-btn {
    width: 40px;
    height: 40px;
  }
  .chat-header {
    padding: 8px 10px;
    gap: 6px;
  }
  .chat-header-info {
    gap: 8px;
  }
  .chat-header-actions {
    gap: 2px;
  }
  #chatHeaderStageBadge {
    display: none;
  }
  .msg-stream {
    padding: 14px 12px;
  }
  .msg-row {
    max-width: 92%;
    flex-wrap: wrap;
  }
  .msg-row:not(.self) .msg-actions-bar {
    margin-left: 40px;
  }
  .msg-img,
  .msg-video {
    max-width: min(248px, 72vw);
  }
  .composer-toolbar .tool-btn {
    min-width: 38px;
    min-height: 36px;
    justify-content: center;
  }
  .form-input,
  .form-select,
  .form-textarea,
  .zalo-search-input,
  .composer-textarea {
    font-size: 16px;
    line-height: 1.4;
  }
  .form-input,
  .form-select {
    height: 40px;
  }
  .composer-toolbar .form-select-sm {
    height: 36px;
    padding: 5px 28px 5px 10px;
    font-size: 14px;
  }

  /* Management Tabs & Modals on Mobile */
  .tab-pane:not(.inbox-pane) {
    padding: 14px 12px 24px;
  }
  .page-container {
    gap: 14px;
  }
  .page-title {
    font-size: 17px;
    line-height: 1.35;
  }
  .grid-4,
  .form-row-2,
  .hs-launcher-grid {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 14px;
  }
  .copy-field-row {
    flex-wrap: wrap;
  }
  .copy-field-row .form-input {
    min-width: 0;
    flex: 1 1 180px;
  }

  .modal-backdrop:not(.lightbox-backdrop) {
    align-items: flex-end;
    padding: 0;
  }
  .modal-backdrop:not(.lightbox-backdrop) .modal-box {
    max-width: 100% !important;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .sticker-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }
  .toast {
    max-width: 100%;
  }
}

/* Very Narrow Phones (320px–374px) */
@media (max-width: 374px) {
  .zalo-count-chip span {
    display: none;
  }
  .nav-tab-label {
    font-size: 11px;
    letter-spacing: -0.25px;
  }
}

/* Coarse Pointer / Touchscreen Support (iPad, Android Tablet, Smartphones) */
@media (hover: none), (pointer: coarse) {
  .msg-row.touch-actions-open {
    flex-wrap: wrap;
  }
  .msg-row.touch-actions-open .msg-actions-bar {
    display: inline-flex;
    margin-top: 2px;
  }
  .msg-row:not(.self).touch-actions-open .msg-actions-bar {
    margin-left: 40px;
  }
  .msg-act-btn {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* Reduced Motion Accessibility (Preserves State Clarity Without Spatial Motion) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
  .rail-brand-btn,
  .rail-avatar-btn,
  .welcome-action-card,
  .hs-progress-fill {
    transition: none !important;
    transform: none !important;
  }
}
