/* ==========================================================================
   NEWSEVEN AI SALES AGENT — AI COMMAND CENTER / MODERN OPERATIONS STUDIO
   ========================================================================== */

:root {
  /* Bảng màu Sáng (Mặc định): Trắng ngà / Xám sáng dịu mắt, Xanh tím hiện đại, Xanh ngọc AI */
  --bg-primary: #f6f7fb;
  --bg-surface: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-subtle: #f1f5f9;
  --bg-hover: #eef2f7;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* Màu chủ đạo: Xanh tím hiện đại (Modern Indigo-Violet) */
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef2ff;
  --brand-border: #c7d2fe;
  --brand-text: #3730a3;

  /* Trạng thái AI hoạt động: Xanh ngọc dịu (Soft Teal) */
  --teal: #0d9488;
  --teal-dot: #14b8a6;
  --teal-soft: #f0fdfa;
  --teal-border: #99f6e4;
  --teal-text: #0f766e;

  /* Cần chú ý / Chờ duyệt: Cam nhạt dịu (Soft Amber) */
  --amber: #d97706;
  --amber-dot: #f59e0b;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #b45309;

  /* Lỗi / Cần nhân viên hỗ trợ: Đỏ hồng dịu (Soft Rose) */
  --rose: #e11d48;
  --rose-dot: #f43f5e;
  --rose-soft: #fff1f2;
  --rose-border: #fecdd3;
  --rose-text: #be123c;

  /* Sidebar đồng bộ hoàn toàn theo giao diện chính (Sáng khi ở chế độ Sáng, Tối khi ở chế độ Tối) */
  --sidebar-bg: #ffffff;
  --sidebar-surface: #f8fafc;
  --sidebar-border: #e2e8f0;
  --sidebar-text: #475569;
  --sidebar-text-bright: #0f172a;
  --sidebar-group: #64748b;
  --sidebar-hover-bg: #f1f5f9;
  --sidebar-active-bg: #eef2ff;
  --sidebar-active-border: #c7d2fe;
  --sidebar-active-text: #3730a3;
  --sidebar-active-icon: #4f46e5;
  --sidebar-count-bg: #f1f5f9;
  --sidebar-count-text: #475569;
  --sidebar-foot-bg: #f8fafc;

  /* Đổ bóng tinh tế & bo góc vừa phải */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.14);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  --transition-fast: 150ms cubic-bezier(0.2, 0, 0, 1);
}

[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-surface: #111827;
  --bg-elevated: #172033;
  --bg-subtle: #1e293b;
  --bg-hover: #243247;

  --border: #1f2937;
  --border-strong: #334155;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --brand: #6366f1;
  --brand-hover: #818cf8;
  --brand-soft: rgba(99, 102, 241, 0.16);
  --brand-border: rgba(129, 140, 248, 0.35);
  --brand-text: #a5b4fc;

  --teal: #14b8a6;
  --teal-dot: #2dd4bf;
  --teal-soft: rgba(20, 184, 166, 0.14);
  --teal-border: rgba(45, 212, 191, 0.32);
  --teal-text: #5eead4;

  --amber: #f59e0b;
  --amber-dot: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --amber-border: rgba(251, 191, 36, 0.32);
  --amber-text: #fcd34d;

  --rose: #f43f5e;
  --rose-dot: #fb7185;
  --rose-soft: rgba(244, 63, 94, 0.15);
  --rose-border: rgba(251, 113, 133, 0.32);
  --rose-text: #fda4af;

  --sidebar-bg: #111827;
  --sidebar-surface: #172033;
  --sidebar-border: #1f2937;
  --sidebar-text: #cbd5e1;
  --sidebar-text-bright: #f1f5f9;
  --sidebar-group: #94a3b8;
  --sidebar-hover-bg: #1e293b;
  --sidebar-active-bg: rgba(99, 102, 241, 0.18);
  --sidebar-active-border: rgba(129, 140, 248, 0.35);
  --sidebar-active-text: #ffffff;
  --sidebar-active-icon: #a5b4fc;
  --sidebar-count-bg: rgba(255, 255, 255, 0.08);
  --sidebar-count-text: #cbd5e1;
  --sidebar-foot-bg: #0d1320;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 52px rgba(0, 0, 0, 0.65);
}

/* Hỗ trợ người dùng giảm chuyển động (System & Toggle thủ công) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

[data-reduced-motion="true"] *,
[data-reduced-motion="true"] *::before,
[data-reduced-motion="true"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

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

html, body {
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text-primary);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ==========================================================================
   APP SHELL & SIDEBAR (MỤC C)
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar-overlay {
  display: none;
}

.sidebar {
  width: 252px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.sidebar-brand {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.38);
  overflow: hidden;
}

.brand-mark-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-copy {
  min-width: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--sidebar-text-bright);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--sidebar-text-bright);
}

.brand-wordmark-ai {
  font-size: 11.5px;
  font-weight: 800;
  padding: 1px 5.5px;
  border-radius: 5px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 65%, #06b6d4 100%);
  color: #ffffff;
  letter-spacing: 0.04em;
  line-height: 1.35;
}

.brand-sub {
  font-size: 11px;
  color: var(--sidebar-text);
  margin-top: 2px;
  letter-spacing: 0.01em;
}

.sidebar-close-btn {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--sidebar-group);
  padding: 0 12px 5px;
  text-transform: uppercase;
}

.nav-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--sidebar-text);
  padding: 9px 12px;
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 500;
  font-size: 13.5px;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

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

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-bright);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  border-color: var(--sidebar-active-border);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--sidebar-active-icon);
  opacity: 1;
}

.nav-count {
  font-size: 11px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--sidebar-count-bg);
  color: var(--sidebar-count-text);
  border: 1px solid var(--border);
  font-weight: 600;
}

.nav-item.active .nav-count {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.nav-count.attention {
  background: var(--rose-soft);
  border-color: var(--rose-border);
  color: var(--rose-text);
}

.sidebar-footer {
  padding: 13px 16px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 11.5px;
  color: var(--sidebar-text);
  background: var(--sidebar-foot-bg);
}

.sidebar-foot-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--sidebar-text-bright);
}

.sidebar-foot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal-dot);
  box-shadow: 0 0 0 3px var(--teal-soft);
  flex-shrink: 0;
}

.sidebar-foot-dot.is-paused {
  background: var(--amber-dot);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.sidebar-foot-dot.is-error {
  background: var(--rose-dot);
  box-shadow: 0 0 0 3px var(--rose-soft);
}

.sidebar-foot-sub {
  margin-top: 3px;
  font-size: 11px;
  color: var(--sidebar-group);
}

/* ==========================================================================
   MAIN WRAPPER & TOP HEADER
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-header {
  min-height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 340px;
}

.header-title-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  white-space: nowrap;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 9px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.header-search {
  flex: 1;
  min-width: 230px;
  max-width: 390px;
}

.search-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field-icon {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 8px 12px 8px 34px;
  border-radius: 9px;
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
  background: var(--bg-surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  outline: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

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

.icon-btn.active-toggle {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-text);
}

/* Live Task Progress Bar (Mục B) */
.live-task-bar {
  background: var(--brand-soft);
  border-bottom: 1px solid var(--brand-border);
  color: var(--brand-text);
  padding: 8px 24px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-task-bar[hidden] {
  display: none !important;
}

.live-task-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--brand-border);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Demo Mode Banner */
.demo-banner {
  background: var(--amber-soft);
  border-bottom: 1px solid var(--amber-border);
  color: var(--amber-text);
  padding: 9px 24px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.demo-banner[hidden] {
  display: none !important;
}

.demo-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-body {
  padding: 22px 24px 36px;
  flex: 1;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

.loading-skeleton-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ==========================================================================
   BADGES, PILLS & BUTTONS
   ========================================================================== */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--teal-dot);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.status-dot.paused {
  background: var(--amber-dot);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.status-dot.error {
  background: var(--rose-dot);
  box-shadow: 0 0 0 3px var(--rose-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge-mode-pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--teal-soft);
  color: var(--teal-text);
  border-color: var(--teal-border);
  letter-spacing: 0.04em;
}

/* ==========================================================================
   THANH TIMELINE TRẠNG THÁI CÔNG CỤ (GLOBAL BAR & OVERVIEW TIMELINE)
   ========================================================================== */
.system-timeline-bar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.system-timeline-bar.state-paused {
  background: var(--amber-soft);
  border-bottom-color: var(--amber-border);
}

.system-timeline-bar.state-error {
  background: var(--rose-soft);
  border-bottom-color: var(--rose-border);
}

.stl-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stl-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11.5px;
  border: 1px solid var(--teal-border);
  background: var(--teal-soft);
  color: var(--teal-text);
}

.stl-live-pill.is-paused {
  border-color: var(--amber-border);
  background: var(--bg-surface);
  color: var(--amber-text);
}

.stl-live-pill.is-error {
  border-color: var(--rose-border);
  background: var(--bg-surface);
  color: var(--rose-text);
}

.stl-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal-dot);
  position: relative;
  flex-shrink: 0;
}

.stl-pulse-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--teal-dot);
  opacity: 0.65;
  animation: stlPulse 2s ease-out infinite;
}

.stl-live-pill.is-paused .stl-pulse-dot {
  background: var(--amber-dot);
}
.stl-live-pill.is-paused .stl-pulse-dot::after {
  border-color: var(--amber-dot);
  animation: none;
}

.stl-live-pill.is-error .stl-pulse-dot {
  background: var(--rose-dot);
}
.stl-live-pill.is-error .stl-pulse-dot::after {
  border-color: var(--rose-dot);
}

@keyframes stlPulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  75% { transform: scale(1.65); opacity: 0; }
  100% { transform: scale(1.65); opacity: 0; }
}

.stl-heartbeat-meta {
  color: var(--text-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.stl-nodes-track {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  justify-content: flex-start;
  min-width: 260px;
  overflow-x: auto;
  padding: 2px 0;
}

.stl-node {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.stl-node:hover {
  border-color: var(--brand-border);
  color: var(--text-primary);
}

.stl-node-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.stl-node.node-ok {
  border-color: var(--teal-border);
}
.stl-node.node-ok .stl-node-dot {
  background: var(--teal-dot);
}

.stl-node.node-warn {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber-text);
}
.stl-node.node-warn .stl-node-dot {
  background: var(--amber-dot);
}

.stl-node.node-err {
  border-color: var(--rose-border);
  background: var(--rose-soft);
  color: var(--rose-text);
}
.stl-node.node-err .stl-node-dot {
  background: var(--rose-dot);
}

.stl-connector {
  width: 10px;
  height: 2px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.stl-connector.conn-ok {
  background: var(--teal-dot);
  opacity: 0.55;
}

.stl-connector.conn-warn {
  background: var(--amber-dot);
  opacity: 0.65;
}

.stl-connector.conn-err {
  background: var(--rose-dot);
  opacity: 0.75;
}

.stl-history-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stl-history-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.stl-segments {
  display: flex;
  align-items: center;
  gap: 3px;
}

.stl-seg {
  width: 7px;
  height: 16px;
  border-radius: 3px;
  background: var(--border-strong);
  transition: transform var(--transition-fast);
}

.stl-seg:hover {
  transform: scaleY(1.2);
}

.stl-seg.seg-ok {
  background: var(--teal-dot);
}

.stl-seg.seg-warn {
  background: var(--amber-dot);
}

.stl-seg.seg-err {
  background: var(--rose-dot);
}

/* Khối Timeline chi tiết trong trang Tổng quan */
.overview-timeline-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}

.ot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ot-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ot-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.ot-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ot-steps-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  position: relative;
}

.ot-step-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.ot-step-box:hover {
  transform: translateY(-1px);
}

.ot-step-box.step-ok {
  border-top-color: var(--teal-dot);
}

.ot-step-box.step-warn {
  border-top-color: var(--amber-dot);
  background: var(--amber-soft);
}

.ot-step-box.step-err {
  border-top-color: var(--rose-dot);
  background: var(--rose-soft);
}

.ot-step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.ot-step-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.ot-step-title {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text-primary);
}

.ot-step-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.badge-active,
.badge-teal {
  background: var(--teal-soft);
  color: var(--teal-text);
  border-color: var(--teal-border);
}

.badge-indigo {
  background: var(--brand-soft);
  color: var(--brand-text);
  border-color: var(--brand-border);
}

.badge-warn,
.badge-amber {
  background: var(--amber-soft);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

.badge-danger,
.badge-rose {
  background: var(--rose-soft);
  color: var(--rose-text);
  border-color: var(--rose-border);
}

.badge-demo {
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px dashed var(--amber-border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Buttons */
.btn {
  background: var(--brand);
  color: #ffffff;
  border: 1px solid var(--brand);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

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

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

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

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

.btn-active-state,
.btn-teal {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.btn-active-state:hover:not(:disabled),
.btn-teal:hover:not(:disabled) {
  background: var(--teal-text);
  border-color: var(--teal-text);
}

.btn-danger-soft {
  background: var(--rose-soft);
  color: var(--rose-text);
  border-color: var(--rose-border);
}

.btn-danger-soft:hover:not(:disabled) {
  background: var(--rose);
  color: #ffffff;
  border-color: var(--rose);
}

.btn-amber-soft {
  background: var(--amber-soft);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

.btn-amber-soft:hover:not(:disabled) {
  background: var(--amber);
  color: #ffffff;
  border-color: var(--amber);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ==========================================================================
   PANELS, CARDS & FORMS
   ========================================================================== */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.panel-title svg {
  color: var(--brand);
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.panel-body {
  padding: 18px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  outline: none;
}

.input.uncertain-cell {
  background: var(--amber-soft);
  border-color: var(--amber);
}

.sizechart-edit-table th,
.sizechart-edit-table td {
  padding: 8px 6px;
}

/* Filter Pill Bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.filter-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.filter-pill .pill-count {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.07);
}

.filter-pill.active .pill-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* ==========================================================================
   MỤC A & B: TRANG TỔNG QUAN (COMMAND HERO + CẦN XỬ LÝ + 4 KPI + HOẠT ĐỘNG)
   ========================================================================== */
.command-top-grid {
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
  align-items: stretch;
}

.agent-hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.agent-hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--teal-dot) 100%);
}

.agent-hero-card.is-paused::before {
  background: var(--amber);
}

.agent-hero-card.is-error::before {
  background: var(--rose);
}

.agent-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.agent-status-headline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-pulse-orb {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--teal-soft);
  color: var(--teal-text);
  border: 1px solid var(--teal-border);
}

.agent-pulse-orb.paused {
  background: var(--amber-soft);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

.agent-pulse-orb.error {
  background: var(--rose-soft);
  color: var(--rose-text);
  border-color: var(--rose-border);
}

.agent-pulse-orb.disconnected {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-color: var(--border);
}

.agent-hero-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.agent-hero-state-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.agent-meta-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.agent-meta-k {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.agent-meta-v {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.agent-latest-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.agent-latest-activity {
  font-size: 12.5px;
  color: var(--text-secondary);
  min-width: 0;
  flex: 1;
}

.agent-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   MINH HỌA ROBOT AI WORKSTATION TOÀN KHUNG (4 MÀN HÌNH THỜI GIAN THỰC & ROBOT)
   ========================================================================== */
.agent-hero-card.agent-workstation-only {
  padding: 0;
  background: #0b1120;
  border-color: #1e293b;
}

.agent-workstation-stage {
  background: linear-gradient(180deg, #090e1a 0%, #0f172a 58%, #1e293b 100%);
  border-radius: inherit;
  padding: 14px 16px 12px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  height: 100%;
  min-height: 365px;
}

.agent-workstation-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(56, 189, 248, 0.14), transparent 42%),
    radial-gradient(circle at 82% 22%, rgba(16, 185, 129, 0.14), transparent 42%),
    radial-gradient(circle at 50% 62%, rgba(99, 102, 241, 0.16), transparent 52%);
  pointer-events: none;
}

/* 1. Thanh điều khiển trung tâm trên cùng */
.aws-top-command-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 3;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.aws-top-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aws-bot-badge {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.35);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.2);
}

.aws-bot-badge.paused {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
}

.aws-bot-badge.error {
  background: rgba(244, 63, 94, 0.16);
  color: #fb7185;
  border-color: rgba(251, 113, 133, 0.35);
}

.aws-top-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.aws-clock-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(14, 165, 233, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 999px;
  padding: 1px 7px;
}

.aws-top-headline {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.aws-state-main {
  font-size: 16.5px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.01em;
}

.aws-top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.aws-btn-chat {
  background: #4f46e5;
  color: #ffffff;
  border: 1px solid #6366f1;
}

.aws-btn-chat:hover {
  background: #4338ca;
}

.aws-btn-pause.btn-secondary {
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  border-color: #475569;
}

.aws-btn-pause.btn-secondary:hover {
  background: #334155;
  color: #ffffff;
}

/* 2. Dàn 4 màn hình cong phía trước mặt Robot (CYBER HUD MONITORS) */
.aws-monitors-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  position: relative;
  z-index: 3;
  perspective: 950px;
  margin-top: 4px;
}

/* Thanh giá đỡ kim loại nối ngang phía sau 4 màn hình */
.aws-monitor-rig-bar {
  position: absolute;
  top: 52%;
  left: 4%;
  right: 4%;
  height: 6px;
  background: linear-gradient(90deg, #1e293b 0%, #475569 25%, #38bdf8 50%, #475569 75%, #1e293b 100%);
  border-top: 1px solid rgba(125, 211, 252, 0.45);
  border-bottom: 1px solid #020617;
  border-radius: 999px;
  z-index: 0;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.aws-screen-card {
  background-color: #050b16;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(56, 189, 248, 0.04) 0px,
      rgba(56, 189, 248, 0.04) 1px,
      transparent 1px,
      transparent 3px
    ),
    linear-gradient(90deg, rgba(56, 189, 248, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(56, 189, 248, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(14, 165, 233, 0.22), rgba(5, 11, 22, 0.96) 75%);
  background-size: 100% 3px, 14px 14px, 14px 14px, 100% 100%;
  border: 1.5px solid rgba(56, 189, 248, 0.52);
  border-radius: 8px;
  padding: 7px 8px 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 122px;
  position: relative;
  z-index: 1;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  box-shadow:
    0 8px 22px rgba(2, 6, 23, 0.65),
    0 0 12px rgba(14, 165, 233, 0.16),
    inset 0 0 18px rgba(14, 165, 233, 0.08);
}

/* 4 Góc ngàm HUD phát sáng trên mỗi màn hình */
.aws-hud-corner {
  position: absolute;
  width: 8px;
  height: 8px;
  border-color: #38bdf8;
  border-style: solid;
  pointer-events: none;
  z-index: 4;
  filter: drop-shadow(0 0 4px #38bdf8);
}
.aws-hud-corner.tl { top: 2px; left: 2px; border-width: 2px 0 0 2px; }
.aws-hud-corner.tr { top: 2px; right: 2px; border-width: 2px 2px 0 0; }
.aws-hud-corner.bl { bottom: 15px; left: 2px; border-width: 0 0 2px 2px; }
.aws-hud-corner.br { bottom: 15px; right: 2px; border-width: 0 2px 2px 0; }

.aws-screen-card.theme-indigo .aws-hud-corner { border-color: #818cf8; filter: drop-shadow(0 0 4px #818cf8); }
.aws-screen-card.theme-teal .aws-hud-corner { border-color: #34d399; filter: drop-shadow(0 0 4px #34d399); }
.aws-screen-card.theme-amber .aws-hud-corner { border-color: #fbbf24; filter: drop-shadow(0 0 4px #fbbf24); }

/* Tia Laser quét dọc màn hình theo thời gian thực */
.aws-laser-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: -20%;
  height: 18px;
  background: linear-gradient(180deg, transparent 0%, rgba(56, 189, 248, 0.16) 85%, rgba(125, 211, 252, 0.45) 100%);
  pointer-events: none;
  z-index: 2;
  animation: awsLaserSweep 3.8s linear infinite;
}
.aws-screen-card.theme-indigo .aws-laser-scan { animation-delay: 0.4s; }
.aws-screen-card.theme-teal .aws-laser-scan { animation-delay: 1.2s; }
.aws-screen-card.theme-amber .aws-laser-scan { animation-delay: 2.1s; }

.aws-screen-card.mon-tilt-left {
  transform: rotateY(9deg) translateY(3px);
  border-color: rgba(129, 140, 248, 0.62);
}

.aws-screen-card.mon-center-left {
  border-color: rgba(56, 189, 248, 0.68);
}

.aws-screen-card.mon-center-right {
  border-color: rgba(52, 211, 153, 0.62);
}

.aws-screen-card.mon-tilt-right {
  transform: rotateY(-9deg) translateY(3px);
  border-color: rgba(251, 191, 36, 0.62);
}

.aws-screen-card:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: #7dd3fc;
  box-shadow:
    0 10px 25px rgba(2, 6, 23, 0.75),
    0 0 18px rgba(56, 189, 248, 0.38),
    inset 0 0 22px rgba(56, 189, 248, 0.14);
}

/* Viền Bezel kim loại cạnh dưới mỗi màn hình */
.aws-screen-bezel-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 5px -8px -5px;
  padding: 2px 8px;
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  border-top: 1px solid rgba(56, 189, 248, 0.28);
}

.aws-bezel-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #64748b;
}

.aws-bezel-power {
  width: 10px;
  height: 3px;
  border-radius: 99px;
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.aws-screen-stand {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 5px;
  border-radius: 0 0 4px 4px;
  background: #475569;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.45);
}

.aws-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.22);
  position: relative;
  z-index: 3;
}

.aws-screen-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #bae6fd;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aws-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.aws-led.ok { background: #10b981; box-shadow: 0 0 7px #10b981; }
.aws-led.warn { background: #f59e0b; box-shadow: 0 0 7px #f59e0b; }
.aws-led.err { background: #f43f5e; box-shadow: 0 0 7px #f43f5e; }

.aws-screen-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(14, 165, 233, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
  white-space: nowrap;
}

.aws-screen-badge.live {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.45);
  animation: awsPulseDot 1.4s ease-in-out infinite;
}

.aws-screen-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  position: relative;
  z-index: 3;
}

.aws-screen-k {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8.5px;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 700;
}

.aws-screen-v {
  font-size: 13px;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.25;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.aws-screen-v small {
  font-size: 9.5px;
  font-weight: 700;
  color: #94a3b8;
}

.aws-screen-v.highlight-indigo { color: #c7d2fe; text-shadow: 0 0 10px rgba(129, 140, 248, 0.4); }
.aws-screen-v.highlight-sky { color: #7dd3fc; text-shadow: 0 0 10px rgba(56, 189, 248, 0.4); }
.aws-screen-v.highlight-teal { color: #6ee7b7; text-shadow: 0 0 10px rgba(52, 211, 153, 0.4); }

/* Cột sóng xung nhịp AI (Neural Spectrum Equalizer) trên Màn 01 */
.aws-eq-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(129, 140, 248, 0.24);
  border-radius: 4px;
  padding: 2.5px 6px;
  margin-top: 1px;
}

.aws-eq-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
}

.aws-eq-bars i {
  display: inline-block;
  width: 2.5px;
  height: 8px;
  border-radius: 1px;
  background: linear-gradient(180deg, #38bdf8 0%, #818cf8 100%);
  transform-origin: bottom;
  animation: awsBarScale 0.65s ease-in-out infinite alternate;
}
.aws-eq-bars i:nth-child(2) { animation-delay: 0.12s; height: 10px; }
.aws-eq-bars i:nth-child(3) { animation-delay: 0.24s; height: 6px; }
.aws-eq-bars i:nth-child(4) { animation-delay: 0.36s; height: 9px; }
.aws-eq-bars i:nth-child(5) { animation-delay: 0.18s; height: 7px; }
.aws-eq-bars i:nth-child(6) { animation-delay: 0.42s; height: 10px; }
.aws-eq-bars i:nth-child(7) { animation-delay: 0.08s; height: 5px; }
.aws-eq-bars i:nth-child(8) { animation-delay: 0.28s; height: 9px; }

.agent-workstation-stage.is-paused .aws-eq-bars i {
  animation: none;
  height: 2px;
  background: #f59e0b;
}

.aws-eq-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 7.5px;
  font-weight: 800;
  color: #a5b4fc;
  letter-spacing: 0.05em;
}

.aws-inline-warn {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: #fda4af;
  background: rgba(244, 63, 94, 0.22);
  border: 1px solid rgba(244, 63, 94, 0.4);
  padding: 0 5px;
  border-radius: 4px;
  margin-left: 3px;
}

.aws-screen-sub {
  margin-top: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
  color: #cbd5e1;
  line-height: 1.35;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(129, 140, 248, 0.2);
  border-radius: 5px;
  padding: 3.5px 6px;
}

.aws-mon-live-box {
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-left: 2.5px solid #38bdf8;
  border-radius: 5px;
  padding: 4px 6px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: inset 0 0 10px rgba(14, 165, 233, 0.08);
}

.aws-mon-scrollable {
  max-height: 62px;
  overflow-y: auto;
  padding-right: 3px;
}

.aws-mon-scrollable::-webkit-scrollbar {
  width: 3.5px;
}
.aws-mon-scrollable::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 99px;
}
.aws-mon-scrollable::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.45);
  border-radius: 99px;
}

.aws-mon-extra-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(148, 163, 184, 0.2);
}

.aws-mon-extra-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 3px;
  border-radius: 3px;
  transition: background 0.15s ease;
}

.aws-mon-extra-item:hover {
  background: rgba(56, 189, 248, 0.14);
}

.aws-mon-live-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.aws-mon-cust,
.aws-mon-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  color: #38bdf8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aws-mon-time {
  font-size: 8px;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
}

.aws-mon-snippet {
  font-size: 9.8px;
  color: #e2e8f0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.aws-blink-cursor {
  display: inline-block;
  color: #38bdf8;
  font-size: 9px;
  animation: awsPulseDot 0.8s steps(2, start) infinite;
}

.aws-mon-sub-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8.5px;
  color: #94a3b8;
}

.aws-channel-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3.5px;
  margin-top: auto;
}

.aws-ch-pill {
  background: rgba(2, 6, 23, 0.68);
  border: 1px solid rgba(52, 211, 153, 0.24);
  border-radius: 4px;
  padding: 2.5px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8.5px;
  font-weight: 700;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aws-ch-pill .dot {
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.aws-ch-pill .dot.ok { background: #10b981; }
.aws-ch-pill .dot.warn { background: #f59e0b; }
.aws-ch-pill .dot.err { background: #f43f5e; }

/* 3. Sân khấu Robot gõ phím & Thanh Terminal dưới cùng */
.aws-canvas {
  width: 100%;
  position: relative;
  z-index: 2;
  margin-top: -2px;
}

.aws-svg {
  width: 100%;
  height: auto;
  max-height: 122px;
  display: block;
}

.aws-desk-live-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(2, 6, 23, 0.78);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 6px 10px;
  position: relative;
  z-index: 3;
}

.aws-desk-prompt {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  color: #34d399;
  white-space: nowrap;
}

.aws-desk-ticker-text {
  font-size: 11.5px;
  font-weight: 600;
  color: #e2e8f0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aws-desk-sync-pill {
  font-size: 10.5px;
  color: #94a3b8;
  white-space: nowrap;
}

.aws-desk-sync-pill strong {
  color: #38bdf8;
}

@media (max-width: 1180px) {
  .aws-monitors-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .aws-screen-card.mon-tilt-left,
  .aws-screen-card.mon-tilt-right {
    transform: none;
  }
}

@media (max-width: 640px) {
  .aws-monitors-grid {
    grid-template-columns: 1fr;
  }
}

/* Chuyển động gõ bàn phím của 2 tay Robot */
.agent-workstation-stage.is-working .aws-arm-left {
  transform-origin: 312px 118px;
  animation: awsTypeLeft 0.34s ease-in-out infinite alternate;
}

.agent-workstation-stage.is-working .aws-arm-right {
  transform-origin: 368px 118px;
  animation: awsTypeRight 0.34s ease-in-out 0.17s infinite alternate;
}

/* Tia sáng nảy lên ngay đầu ngón tay khi gõ phím */
.agent-workstation-stage.is-working .spark-l {
  animation: awsKeySpark 0.34s ease-out infinite alternate;
}

.agent-workstation-stage.is-working .spark-r {
  animation: awsKeySpark 0.34s ease-out 0.17s infinite alternate;
}

/* Đầu Robot đảo nhẹ quan sát 4 màn hình */
.agent-workstation-stage.is-working .aws-robot-head {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: awsHeadLook 4.2s ease-in-out infinite;
}

/* Mắt Robot chớp tự nhiên */
.agent-workstation-stage.is-working .aws-eye-l,
.agent-workstation-stage.is-working .aws-eye-r {
  transform-box: fill-box;
  transform-origin: center;
  animation: awsEyeBlink 3.6s ease-in-out infinite;
}

/* Đèn ăng-ten phát tín hiệu */
.agent-workstation-stage.is-working .aws-antenna-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: awsAntennaPing 1.8s ease-out infinite;
}

/* Phím cơ nhấp nháy theo nhịp gõ */
.agent-workstation-stage.is-working .aws-key.k1 { animation: awsKeyFlash 0.55s infinite alternate; }
.agent-workstation-stage.is-working .aws-key.k2 { animation: awsKeyFlash 0.65s 0.15s infinite alternate; }
.agent-workstation-stage.is-working .aws-key.k3 { animation: awsKeyFlash 0.45s 0.25s infinite alternate; }
.agent-workstation-stage.is-working .aws-key.k4 { animation: awsKeyFlash 0.70s 0.10s infinite alternate; }
.agent-workstation-stage.is-working .aws-key.k5 { animation: awsKeyFlash 0.50s 0.30s infinite alternate; }
.agent-workstation-stage.is-working .aws-key.k6 { animation: awsKeyFlash 0.60s 0.20s infinite alternate; }

/* Dòng tín hiệu chạy từ bàn phím lên 4 màn hình */
.agent-workstation-stage.is-working .aws-cable {
  animation: awsCableFlow 1.2s linear infinite;
}

/* Màn hình 1: Dấu 3 chấm đang gõ tin nhắn */
.agent-workstation-stage.is-working .aws-typing-dot.d1 { animation: awsDotBounce 0.9s infinite 0s; }
.agent-workstation-stage.is-working .aws-typing-dot.d2 { animation: awsDotBounce 0.9s infinite 0.2s; }
.agent-workstation-stage.is-working .aws-typing-dot.d3 { animation: awsDotBounce 0.9s infinite 0.4s; }

/* Màn hình 2: Code & Nơ-ron AI */
.agent-workstation-stage.is-working .aws-code-bar {
  transform-box: fill-box;
  transform-origin: left center;
  animation: awsCodePulse 1.6s ease-in-out infinite alternate;
}
.agent-workstation-stage.is-working .aws-code-bar.b2 { animation-delay: 0.25s; }
.agent-workstation-stage.is-working .aws-code-bar.b3 { animation-delay: 0.50s; }
.agent-workstation-stage.is-working .aws-code-bar.b4 { animation-delay: 0.75s; }
.agent-workstation-stage.is-working .aws-code-bar.b5 { animation-delay: 1.00s; }

.agent-workstation-stage.is-working .aws-node-pulse {
  animation: awsPulseDot 1.2s ease-in-out infinite alternate;
}

/* Màn hình 3: Biểu đồ kho & thanh quét size */
.agent-workstation-stage.is-working .aws-bar {
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: awsBarScale 1.8s ease-in-out infinite alternate;
}
.agent-workstation-stage.is-working .aws-bar.bar-2 { animation-delay: 0.3s; }
.agent-workstation-stage.is-working .aws-bar.bar-3 { animation-delay: 0.6s; }
.agent-workstation-stage.is-working .aws-bar.bar-4 { animation-delay: 0.9s; }
.agent-workstation-stage.is-working .aws-bar.bar-5 { animation-delay: 1.2s; }

.agent-workstation-stage.is-working .aws-scan-bar {
  animation: awsScanSlide 2s ease-in-out infinite alternate;
}

/* Khói cốc cà phê & Ký tự bay lên từ bàn phím */
.aws-steam.s1 { animation: awsSteamRise 2.2s ease-in-out infinite; }
.aws-steam.s2 { animation: awsSteamRise 2.2s ease-in-out 1.1s infinite; }

.aws-float-sym.sym-1 { animation: awsSymbolFloat 2.1s ease-out infinite; }
.aws-float-sym.sym-2 { animation: awsSymbolFloat 2.4s ease-out 0.7s infinite; }
.aws-float-sym.sym-3 { animation: awsSymbolFloat 2.0s ease-out 1.3s infinite; }

@keyframes awsTypeLeft {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-4.5px) rotate(-2.5deg); }
}

@keyframes awsTypeRight {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-4.5px) rotate(2.5deg); }
}

@keyframes awsKeySpark {
  0% { opacity: 0.85; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.6); }
}

@keyframes awsHeadLook {
  0%, 100% { transform: translate(298px, 46px) rotate(0deg); }
  25% { transform: translate(295px, 45px) rotate(-3.5deg); }
  50% { transform: translate(298px, 47px) rotate(0.5deg); }
  75% { transform: translate(301px, 45px) rotate(3.5deg); }
}

@keyframes awsEyeBlink {
  0%, 44%, 50%, 94%, 100% { transform: scaleY(1); }
  47%, 97% { transform: scaleY(0.12); }
}

@keyframes awsAntennaPing {
  0% { transform: scale(0.75); opacity: 0.9; }
  100% { transform: scale(1.65); opacity: 0; }
}

@keyframes awsKeyFlash {
  0% { opacity: 0.45; }
  100% { opacity: 1; filter: drop-shadow(0 0 3px #38bdf8); }
}

@keyframes awsCableFlow {
  to { stroke-dashoffset: -16; }
}

@keyframes awsDotBounce {
  0%, 100% { transform: translateY(0); opacity: 0.45; }
  50% { transform: translateY(-2.5px); opacity: 1; }
}

@keyframes awsCodePulse {
  0% { transform: scaleX(0.68); opacity: 0.65; }
  100% { transform: scaleX(1.04); opacity: 1; }
}

@keyframes awsBarScale {
  0% { transform: scaleY(0.76); }
  100% { transform: scaleY(1.06); }
}

@keyframes awsScanSlide {
  0% { width: 10px; }
  100% { width: 34px; }
}

@keyframes awsSteamRise {
  0% { transform: translateY(2px); opacity: 0; }
  50% { opacity: 0.75; }
  100% { transform: translateY(-5px); opacity: 0; }
}

@keyframes awsSymbolFloat {
  0% { transform: translateY(4px); opacity: 0; }
  35% { opacity: 0.95; }
  100% { transform: translateY(-14px); opacity: 0; }
}

@keyframes awsPulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes awsLaserSweep {
  0% { top: -25%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 105%; opacity: 0; }
}

/* Khối "Cần xử lý" (Triage Card - Mở rộng hiển thị chi tiết & cuộn xử lý) */
.triage-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.triage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.triage-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.triage-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.triage-filter-all-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.triage-filter-all-btn:hover {
  border-color: var(--brand-border);
  color: var(--text-primary);
}

.triage-filter-all-btn.active {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-text);
}

.triage-jump-btn {
  font-size: 11.5px;
  padding: 4px 8px;
  height: auto;
}

/* 4 Ô danh mục tóm tắt ngang (Filter Tiles) */
.triage-cat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.triage-cat-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 9px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all var(--transition-fast);
}

.triage-cat-tile:hover {
  background: var(--bg-hover);
  border-color: var(--brand-border);
  transform: translateY(-1px);
}

.triage-cat-tile.active.tone-rose {
  background: var(--rose-soft);
  border-color: var(--rose-border);
  box-shadow: 0 0 0 1px var(--rose-border);
}

.triage-cat-tile.active.tone-amber {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  box-shadow: 0 0 0 1px var(--amber-border);
}

.triage-cat-tile.active.tone-indigo {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  box-shadow: 0 0 0 1px var(--brand-border);
}

.tct-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
}

.tct-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tct-icon svg {
  width: 14px;
  height: 14px;
}
.tct-icon.rose { background: var(--rose-soft); color: var(--rose-text); }
.tct-icon.amber { background: var(--amber-soft); color: var(--amber-text); }
.tct-icon.indigo { background: var(--brand-soft); color: var(--brand-text); }

.tct-count {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.tct-count.has-rose {
  background: var(--rose-soft);
  border-color: var(--rose-border);
  color: var(--rose-text);
}
.tct-count.has-amber {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

.tct-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tct-sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Khu vực cuộn danh sách các mục cần xử lý chi tiết */
.triage-scroll-queue {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 210px;
  min-height: 170px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
}

.triage-scroll-queue::-webkit-scrollbar {
  width: 6px;
}
.triage-scroll-queue::-webkit-scrollbar-track {
  background: var(--bg-subtle);
  border-radius: 999px;
}
.triage-scroll-queue::-webkit-scrollbar-thumb {
  background: var(--border-strong, #cbd5e1);
  border-radius: 999px;
}
.triage-scroll-queue::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.triage-detail-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.triage-detail-item:hover {
  background: var(--bg-hover);
  border-color: var(--brand-border);
}

.tdi-left {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.tdi-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.tdi-head-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tdi-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  white-space: nowrap;
}
.tdi-badge.tone-rose {
  background: var(--rose-soft);
  color: var(--rose-text);
  border: 1px solid var(--rose-border);
}
.tdi-badge.tone-amber {
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
}
.tdi-badge.tone-indigo {
  background: var(--brand-soft);
  color: var(--brand-text);
  border: 1px solid var(--brand-border);
}

.tdi-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.tdi-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: auto;
  white-space: nowrap;
}

.tdi-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.35;
  max-height: 42px;
  overflow-y: auto;
  padding-right: 2px;
}

.tdi-right {
  flex-shrink: 0;
}

.tdi-action-btn {
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  gap: 4px;
}

.triage-empty-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 16px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin: auto 0;
}

.triage-empty-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-text);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.triage-empty-box strong {
  font-size: 13px;
  color: var(--text-primary);
  display: block;
}

.triage-empty-box p {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.triage-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .triage-cat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.triage-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.triage-icon.rose {
  background: var(--rose-soft);
  color: var(--rose-text);
}

.triage-icon.amber {
  background: var(--amber-soft);
  color: var(--amber-text);
}

.triage-icon.indigo {
  background: var(--brand-soft);
  color: var(--brand-text);
}

.triage-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.triage-row-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.triage-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.triage-count {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.triage-count.has-items-rose {
  background: var(--rose-soft);
  border-color: var(--rose-border);
  color: var(--rose-text);
}

.triage-count.has-items-amber {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

/* 4 Thẻ chỉ số KPI (Mục A.3) */
.kpi-four-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card:hover {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-sm);
}

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

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-icon-box {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.kpi-icon-box.teal { background: var(--teal-soft); color: var(--teal-text); }
.kpi-icon-box.indigo { background: var(--brand-soft); color: var(--brand-text); }
.kpi-icon-box.rose { background: var(--rose-soft); color: var(--rose-text); }
.kpi-icon-box.amber { background: var(--amber-soft); color: var(--amber-text); }

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-foot {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* Khung cuộn cho các bảng & danh sách khi vượt phạm vi hiển thị */
.panel-scroll-box {
  max-height: 360px;
  overflow-y: auto;
  overflow-x: auto;
}

.panel-scroll-box thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-subtle);
  box-shadow: 0 1px 0 var(--border);
}

.panel-scroll-box::-webkit-scrollbar,
.activity-feed::-webkit-scrollbar,
.cell-scroll-text::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.panel-scroll-box::-webkit-scrollbar-track,
.activity-feed::-webkit-scrollbar-track,
.cell-scroll-text::-webkit-scrollbar-track {
  background: var(--bg-subtle);
  border-radius: 999px;
}

.panel-scroll-box::-webkit-scrollbar-thumb,
.activity-feed::-webkit-scrollbar-thumb,
.cell-scroll-text::-webkit-scrollbar-thumb {
  background: var(--border-strong, #cbd5e1);
  border-radius: 999px;
}

.panel-scroll-box::-webkit-scrollbar-thumb:hover,
.activity-feed::-webkit-scrollbar-thumb:hover,
.cell-scroll-text::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.cell-scroll-text {
  max-height: 48px;
  overflow-y: auto;
  line-height: 1.38;
  padding-right: 3px;
  word-break: break-word;
}

/* Activity Timeline (Mục B: Hoạt động gần đây) */
.activity-feed {
  display: flex;
  flex-direction: column;
  max-height: 380px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-item.clickable {
  cursor: pointer;
}

.activity-item.clickable:hover {
  background: var(--bg-elevated);
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.activity-icon.cat-receive_conv { background: var(--brand-soft); color: var(--brand-text); }
.activity-icon.cat-ai_reply { background: var(--teal-soft); color: var(--teal-text); }
.activity-icon.cat-draft_order { background: var(--amber-soft); color: var(--amber-text); }
.activity-icon.cat-handoff { background: var(--rose-soft); color: var(--rose-text); }
.activity-icon.cat-check_product { background: var(--bg-subtle); color: var(--text-primary); }
.activity-icon.cat-connection_error { background: var(--rose-soft); color: var(--rose-text); }

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

.activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.activity-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.activity-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.activity-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* ==========================================================================
   TABLES & EMPTY STATES
   ========================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

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

tbody tr:hover td {
  background: var(--bg-elevated);
}

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-state-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

/* ==========================================================================
   MỤC D: TRANG HỘI THOẠI (3 CỘT DESKTOP / TÁCH MÀN HÌNH MOBILE)
   ========================================================================== */
.conv-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 330px;
  gap: 14px;
  height: calc(100vh - 118px);
  min-height: 580px;
}

.conv-col {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.conv-mobile-nav {
  display: none;
}

.conv-list-toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
}

.conv-list {
  flex: 1;
  overflow-y: auto;
}

.conv-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  transition: background var(--transition-fast);
}

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

.conv-item.active {
  background: var(--brand-soft);
  border-left: 3px solid var(--brand);
  padding-left: 11px;
}

.avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-text);
  border: 1px solid var(--brand-border);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.avatar-circle.needs-support {
  background: var(--rose-soft);
  color: var(--rose-text);
  border-color: var(--rose-border);
}

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

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

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

.conv-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.conv-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* Chat Stream & Bubbles */
.chat-header-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-surface);
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: var(--shadow-xs);
  position: relative;
}

.chat-bubble.customer {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

.chat-bubble.ai {
  align-self: flex-end;
  background: var(--teal-soft);
  border: 1px solid var(--teal-border);
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}

.chat-bubble.staff {
  align-self: flex-end;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.bubble-role-tag {
  font-weight: 700;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chat-bubble.ai .bubble-role-tag {
  color: var(--teal-text);
}

.chat-bubble.staff .bubble-role-tag {
  color: var(--brand-text);
}

.chat-composer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.composer-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Right Column Info Blocks */
.conv-info-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.info-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.linked-product-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.linked-product-thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}

/* ==========================================================================
   MỤC E: TRANG SẢN PHẨM (ẢNH ĐẠI DIỆN + ĐỐI CHIẾU GIÁ WEB)
   ========================================================================== */
.product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.product-thumb {
  width: 52px;
  height: 52px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}

.product-title-link {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.35;
  cursor: pointer;
}

.product-title-link:hover {
  color: var(--brand);
}

.price-now-strong {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.price-orig-strike {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}

.prod-mobile-cards {
  display: none;
}

/* ==========================================================================
   MỤC F: TRANG BẢNG SIZE (2 CỘT: ẢNH ZOOM BÊN TRÁI + BẢNG DUYỆT BÊN PHẢI)
   ========================================================================== */
.sizechart-selector-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.sizechart-tab-card {
  min-width: 210px;
  max-width: 250px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  text-align: left;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.sizechart-tab-card:hover {
  background: var(--bg-hover);
}

.sizechart-tab-card.active {
  background: var(--brand-soft);
  border-color: var(--brand);
}

.sizechart-image-stage {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: 540px;
  padding: 14px;
  text-align: center;
}

.sizechart-image-stage img {
  height: auto;
  border-radius: 8px;
  transition: width var(--transition-fast);
}

.uncertain-alert-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
  border-radius: 10px;
  color: var(--amber-text);
  font-size: 12.5px;
}

/* ==========================================================================
   MỤC G: TRANG ĐƠN NHÁP (BẢNG DESKTOP + DẠNG THẺ MOBILE)
   ========================================================================== */
.draft-mobile-cards {
  display: none;
}

.draft-card-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   MỤC H: TRANG KẾT NỐI (5 MODULE CARDS + 3 TRẠNG THÁI TELEGRAM RIÊNG)
   ========================================================================== */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.integration-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.integration-card.span-full {
  grid-column: 1 / -1;
}

.integration-card-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.integration-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-text);
  border: 1px solid var(--brand-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.tg-check-step {
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tg-check-step.ok {
  background: var(--teal-soft);
  border-color: var(--teal-border);
}

.tg-check-step.pending {
  background: var(--amber-soft);
  border-color: var(--amber-border);
}

.tg-check-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.tg-check-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.guide-drawer {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ==========================================================================
   MODAL & TOAST
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

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

.toast-item {
  pointer-events: auto;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

/* ==========================================================================
   RESPONSIVE: IPAD / TABLET (max-width: 1080px) & IPHONE / MOBILE (max-width: 768px)
   ========================================================================== */
@media (max-width: 1080px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease, visibility 0.22s ease;
    box-shadow: none;
    visibility: hidden;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
    visibility: visible;
  }

  .sidebar-overlay.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    z-index: 45;
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .command-top-grid {
    grid-template-columns: 1fr;
  }

  .kpi-four-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col-grid,
  .integrations-grid {
    grid-template-columns: 1fr;
  }

  .conv-layout {
    grid-template-columns: 290px minmax(0, 1fr);
    height: calc(100vh - 108px);
  }

  .conv-col.conv-col-info {
    display: none;
  }

  .conv-layout[data-tablet-info="open"] {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .conv-layout[data-tablet-info="open"] .conv-col.conv-col-list {
    display: none;
  }

  .conv-layout[data-tablet-info="open"] .conv-col.conv-col-info {
    display: flex;
  }
}

@media (max-width: 768px) {
  .top-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .page-subtitle,
  .hide-mobile {
    display: none !important;
  }

  .header-left {
    max-width: none;
  }

  .header-search {
    order: 3;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 100%;
  }

  .content-body {
    padding: 14px 14px 28px;
  }

  .agent-meta-grid,
  .telegram-checklist-grid {
    grid-template-columns: 1fr;
  }

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

  .kpi-card {
    padding: 13px 14px;
  }

  .kpi-value {
    font-size: 23px;
  }

  /* Tách riêng màn hình danh sách / nội dung chat / thông tin trên iPhone (Mục D & I) */
  .conv-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  .conv-list-scroll {
    max-height: 62vh;
  }

  .chat-stream {
    max-height: 45vh;
    min-height: 240px;
  }

  .conv-mobile-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
  }

  .conv-layout[data-mobile-pane="list"] .conv-col-list {
    display: flex;
    flex: 1;
  }
  .conv-layout[data-mobile-pane="list"] .conv-col-chat,
  .conv-layout[data-mobile-pane="list"] .conv-col-info {
    display: none !important;
  }

  .conv-layout[data-mobile-pane="chat"] .conv-col-chat {
    display: flex;
    flex: 1;
  }
  .conv-layout[data-mobile-pane="chat"] .conv-col-list,
  .conv-layout[data-mobile-pane="chat"] .conv-col-info {
    display: none !important;
  }

  .conv-layout[data-mobile-pane="info"] .conv-col-info {
    display: flex;
    flex: 1;
  }
  .conv-layout[data-mobile-pane="info"] .conv-col-list,
  .conv-layout[data-mobile-pane="info"] .conv-col-chat {
    display: none !important;
  }

  .chat-bubble {
    max-width: 90%;
  }

  .composer-input-row {
    flex-wrap: wrap;
  }

  .composer-input-row .input {
    flex: 1 1 100%;
    font-size: 16px; /* Ngăn iOS Safari tự phóng to khi gõ */
  }

  input.input,
  select.input,
  textarea.input,
  .search-input {
    font-size: 16px;
  }

  .btn, .btn-sm {
    min-height: 38px;
  }

  /* Đơn nháp & Sản phẩm chuyển sang dạng Thẻ dễ đọc trên iPhone (Mục G & I) */
  .desktop-only-table {
    display: none !important;
  }

  .draft-mobile-cards,
  .prod-mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .modal-card {
    max-height: 92vh;
    border-radius: 16px 16px 12px 12px;
  }

  .system-timeline-bar {
    padding: 8px 14px;
    gap: 8px;
  }

  .stl-nodes-track {
    justify-content: flex-start;
    min-width: 100%;
    order: 3;
  }

  .ot-steps-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) and (min-width: 769px) {
  .ot-steps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================================================
   2-WAY CHAT IMAGE ATTACHMENTS & AI VISION PICKER
   ========================================================================== */
.chat-attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.chat-attachments-grid.single-att {
  grid-template-columns: minmax(140px, 240px);
}

.chat-att-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.chat-att-card:hover {
  transform: translateY(-1px);
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.chat-att-card img {
  width: 100%;
  height: 145px;
  object-fit: cover;
  display: block;
  background: var(--bg-subtle);
}

.chat-attachments-grid.single-att .chat-att-card img {
  height: 190px;
}

.chat-att-caption {
  padding: 5px 8px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-tools-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.composer-pending-atts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.composer-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 4px 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 11.5px;
  color: var(--text-primary);
}

.composer-att-chip img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 5px;
}

.composer-att-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

.composer-att-remove:hover {
  color: var(--rose);
}

.image-picker-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 2px;
}

.image-picker-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.image-picker-card img {
  width: 100%;
  height: 132px;
  object-fit: cover;
  background: var(--bg-subtle);
}

.image-picker-card-body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.image-picker-sku {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--brand-text);
}

.image-picker-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-picker-actions {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ==========================================================================
   HUMAN-LIKE PACING & ANTI-SPAM TELEMETRY IN CHAT
   ========================================================================== */
.bubble-pacing-foot {
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px dashed var(--teal-border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pacing-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.pacing-chip.coalesced {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-text);
}

.pacing-chip.safe {
  background: var(--teal-soft);
  border-color: var(--teal-border);
  color: var(--teal-text);
}

.typing-indicator-bubble {
  padding: 10px 14px;
  border-style: dashed;
}

.typing-stage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--teal-text);
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ==========================================================================
   BÁO CÁO HOẠT ĐỘNG AI (AI ACTIVITY REPORT — TAB "BÁO CÁO AI")
   ========================================================================== */
.aireport-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.aireport-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.aireport-filter-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.aireport-preset-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.aireport-preset-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.aireport-preset-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.aireport-preset-btn.active {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.aireport-date-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.aireport-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.aireport-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}

.aireport-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

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

.aireport-kpi-icon.teal {
  background: var(--teal-soft);
  color: var(--teal-text);
}

.aireport-kpi-icon.indigo {
  background: var(--brand-soft);
  color: var(--brand-text);
}

.aireport-kpi-icon.purple {
  background: rgba(168, 85, 247, 0.12);
  color: #9333ea;
}

[data-theme="dark"] .aireport-kpi-icon.purple {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
}

.aireport-kpi-icon.amber {
  background: var(--amber-soft);
  color: var(--amber-text);
}

.aireport-kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.aireport-kpi-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.aireport-kpi-delta {
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.aireport-kpi-delta.up {
  color: var(--teal-text);
}

.aireport-kpi-delta.down {
  color: var(--rose-text);
}

.aireport-kpi-delta.warn {
  color: var(--amber-text);
}

.aireport-kpi-delta.neutral {
  color: var(--text-muted);
}

.aireport-charts-grid {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 16px;
}

.aireport-chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.aireport-stacked-bars-wrap {
  position: relative;
  height: 230px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-top: 22px;
}

.aireport-bars-track {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  height: 185px;
  border-bottom: 1px solid var(--border);
  padding: 0 6px;
}

.aireport-bar-col {
  flex: 1;
  min-width: 18px;
  max-width: 58px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  cursor: pointer;
}

.aireport-bar-total {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.aireport-bar-stack {
  width: 100%;
  max-width: 44px;
  border-radius: 6px 6px 2px 2px;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.aireport-bar-col:hover .aireport-bar-stack {
  filter: brightness(1.06);
  transform: translateY(-2px);
}

.aireport-bar-seg.msg {
  background: #4f46e5;
}

.aireport-bar-seg.cmt {
  background: #0d9488;
}

.aireport-bar-seg.draft {
  background: #a855f7;
}

.aireport-bar-x {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 7px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.aireport-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
}

.aireport-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.aireport-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.aireport-donut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin: auto 0;
}

.aireport-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 145px;
}

.aireport-donut-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.aireport-alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
}

.aireport-alert-banner.is-critical {
  background: var(--rose-soft);
  border-color: var(--rose-border);
}

.aireport-alert-banner.is-healthy {
  background: var(--teal-soft);
  border-color: var(--teal-border);
}

@media (max-width: 1240px) {
  .aireport-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .aireport-charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .aireport-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .aireport-bars-track {
    overflow-x: auto;
    justify-content: flex-start;
  }
}

/* ==========================================================================
   TRẠNG THÁI GỬI TIN NHẮN TRONG HỘI THOẠI (ĐÃ GỬI KHÁCH / CHƯA GỬI / LỖI)
   ========================================================================== */
.chat-bubble.bubble-delivery-draft {
  border-style: dashed;
  border-width: 1.5px;
  border-color: var(--amber-border);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--amber-soft) 100%);
}

.chat-bubble.bubble-delivery-failed {
  border-width: 1.5px;
  border-color: var(--rose-border);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--rose-soft) 100%);
}

.chat-bubble.bubble-delivery-sent {
  border-left: 3.5px solid var(--teal);
}

.msg-delivery-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.msg-delivery-pill.is-sent,
.msg-delivery-pill.is-sent-approved {
  background: var(--teal-soft);
  color: var(--teal-text);
  border: 1px solid var(--teal-border);
}

.msg-delivery-pill.is-unsent {
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
}

.msg-delivery-pill.is-failed {
  background: var(--rose-soft);
  color: var(--rose-text);
  border: 1px solid var(--rose-border);
}

.msg-delivery-status-bar {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11.5px;
  line-height: 1.4;
}

.msg-delivery-status-bar.is-unsent {
  background: var(--amber-soft);
  border: 1px dashed var(--amber-border);
  color: var(--amber-text);
}

.msg-delivery-status-bar.is-failed {
  background: var(--rose-soft);
  border: 1px solid var(--rose-border);
  color: var(--rose-text);
}

.msg-delivery-status-bar.is-sent {
  background: var(--teal-soft);
  border: 1px solid var(--teal-border);
  color: var(--teal-text);
}

.msg-delivery-status-info {
  flex: 1;
  min-width: 190px;
}

.msg-delivery-status-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}




