@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap");

/* ==========================================================================
   AgentOS Simplified Bento Design System (v5.2)
   Dark Theme Deep Obsidian Emerald · Minimal Clean Architecture
   ========================================================================== */

:root {
  --bg:        #121110;
  --surface:   #1A1816;
  --surface-2: #221F1C;
  --border:    #2E2A26;
  --text:      #EDE7DC;
  --text-dim:  #968E82;
  --accent:    #E6D9BF;  /* chữ trên accent: #14110F */
  --success:   #9DBF8E;
  --warning:   #E0B458;
  --danger:    #E0705F;
  --info:      #7FA6C4;

  /* Ánh xạ hệ thống biến nội bộ sang bảng màu chuẩn của Martin */
  --bg-canvas: var(--bg);
  --bg-frame: var(--surface);
  --bg-sidebar: var(--surface);
  --bg-panel: var(--surface-2);
  --bg-card: var(--surface);
  --bg-card-hover: var(--surface-2);
  --bg-card-active: var(--surface-2);
  --bg-terminal: var(--bg);
  --bg-subtle: rgba(230, 217, 191, 0.04);

  --border-subtle: var(--border);
  --border-card: var(--border);
  --border-emerald: var(--accent);
  --border-bright: #3D3833;

  --text-main: var(--text);
  --text-secondary: var(--text);
  --text-muted: var(--text-dim);

  --emerald: var(--success);
  --emerald-glow: rgba(157, 191, 142, 0.22);
  --cyan: var(--info);
  --cyan-glow: rgba(127, 166, 196, 0.24);
  --amber: var(--warning);
  --amber-glow: rgba(224, 180, 88, 0.24);
  --red: var(--danger);
  --red-glow: rgba(224, 112, 95, 0.24);
  --slate: var(--text-dim);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;

  --text-xs: 13px;
  --text-sm: 13.5px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 26px;
  --text-hero: 34px;

  --sp-xs: 6px;
  --sp-sm: 10px;
  --sp-md: 16px;
  --sp-lg: 22px;
  --sp-xl: 30px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --shadow-glow-emerald: 0 0 20px rgba(230, 217, 191, 0.16);
  --shadow-glow-cyan: 0 0 20px rgba(127, 166, 196, 0.22);
}

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

html,
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.font-mono {
  font-family: var(--font-mono);
}

.font-muted {
  color: var(--text-muted);
}

/* ==========================================================================
   MOCK SCENARIO SWITCHER BAR (?mock=1)
   ========================================================================== */
.mock-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.mock-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(230, 217, 191, 0.14);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.mock-scenario-list {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.mock-scn-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: var(--text-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.mock-scn-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--border-bright);
}

.mock-scn-btn.active {
  background: var(--accent);
  color: #14110F;
  font-weight: 600;
  border-color: var(--accent);
}

/* ==========================================================================
   AGENTOS FRAME & LAYOUT
   ========================================================================== */
.agentos-frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
}

/* 1. TOP GLOBAL HEADER BAR */
.agentos-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-frame);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topbar-brand-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.agentos-logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
}

.agentos-brand-name {
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.agentos-sparkle {
  color: #34d399;
  font-size: 12px;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--slate);
  margin-left: 6px;
}

.brand-dot.ok {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.brand-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* TOPBAR CENTER: PROJECT PICKER & SEARCH */
.topbar-center-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 620px;
}

.topbar-select {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.topbar-select:hover,
.topbar-select:focus {
  border-color: var(--border-emerald);
}

.topbar-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  flex: 1;
  transition: border-color 0.15s;
}

.topbar-search-box:focus-within {
  border-color: var(--border-emerald);
  box-shadow: 0 0 0 1px var(--emerald-glow);
}

.topbar-search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  width: 100%;
  font-size: var(--text-xs);
}

.topbar-search-box input::placeholder {
  color: var(--text-dim);
}

.search-icon {
  color: var(--text-dim);
  display: flex;
  align-items: center;
}

/* TOPBAR ACTIONS RIGHT */
.topbar-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.gate-banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(245, 158, 11, 0.4); }
  50% { border-color: rgba(245, 158, 11, 0.85); box-shadow: 0 0 10px var(--amber-glow); }
}

.gate-alert-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: #f59e0b;
}

.icon-circle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.icon-circle-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-bright);
}

.avatar-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 3px 10px 3px 4px;
  border-radius: var(--radius-pill);
}

.avatar-ring {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #14110F;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-role-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

/* SYSTEM STATE BANNER (401 / MẤT MẠNG / READONLY) */
.system-state-banner {
  padding: 10px 20px;
  font-size: var(--text-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid transparent;
}

.system-state-banner.banner-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.system-state-banner.banner-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.system-state-banner.banner-info {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.3);
}

/* ==========================================================================
   2. MAIN SHELL (SIDEBAR 4 MỤC + WORKSPACE)
   ========================================================================== */
.app-shell {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 60px);
}

/* SIDEBAR TRÁI: ĐÚNG 4 MỤC */
.studio-sidebar {
  width: 210px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

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

.nav-item-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-item-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item-btn.active {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-text {
  flex: 1;
}

.nav-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.nav-pill.pill-cyan {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.sidebar-bottom {
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.version-label {
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 500;
}

.live-clock {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   VÙNG KHÔNG GIAN NỘI DUNG (MAIN STAGE)
   ========================================================================== */
.studio-main {
  flex: 1;
  min-width: 0;
  padding: 22px 28px;
  overflow-y: auto;
  max-width: 100%;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 4px;
  max-width: 680px;
}

.header-breadcrumb {
  font-size: var(--text-xs);
  color: var(--text-dim);
  margin-bottom: 4px;
}

.header-breadcrumb span {
  cursor: pointer;
  color: var(--emerald);
}

/* ==========================================================================
   MÀN HÌNH 1: TỔNG QUAN (4 CHỈ SỐ LỚN + CẦN XỬ LÝ + MÁY)
   ========================================================================== */
.kpi-hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 26px;
}

.kpi-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s, border-color 0.15s;
}

.kpi-hero-card:hover {
  border-color: var(--border-card);
  transform: translateY(-1px);
}

.kpi-hero-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.kpi-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
}

.dot-running { background: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }
.dot-warning { background: var(--amber); box-shadow: 0 0 8px var(--amber-glow); }
.dot-danger { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }
.dot-success { background: var(--emerald); box-shadow: 0 0 8px var(--emerald-glow); }

.kpi-hero-title {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-hero-val {
  font-size: var(--text-hero);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  font-family: var(--font-sans);
}

.num-cyan { color: #38bdf8; }
.num-warning { color: #f59e0b; }
.num-danger { color: #ef4444; }
.num-success { color: #10b981; }

.kpi-hero-desc {
  font-size: var(--text-xs);
  color: var(--text-dim);
}

/* BỐ CỤC 2 CỘT TỔNG QUAN */
.overview-split-layout {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 20px;
}

.panel-card-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.panel-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text-main);
}

.badge-count {
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}

/* KHỐI CẦN BẠN XỬ LÝ */
.action-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: all 0.15s ease;
}

.action-item-row:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-bright);
}

.action-item-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.action-item-icon {
  font-size: 16px;
  line-height: 1.2;
}

.action-item-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-main);
}

.action-item-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.action-item-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* KHỐI MÁY / AGENT NHỎ */
.machine-mini-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.machine-mini-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.machine-mini-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-emerald);
}

.machine-mini-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.machine-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
}

.machine-status-dot.online { background: var(--emerald); box-shadow: 0 0 6px var(--emerald); }
.machine-status-dot.busy { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.machine-status-dot.offline { background: var(--slate); }
.machine-status-dot.revoked { background: var(--red); }

.machine-name-text {
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.machine-task-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.machine-mini-metric {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-dim);
}

/* ==========================================================================
   MÀN HÌNH 2: DỰ ÁN & LUỒNG GIAO VIỆC 3 BƯỚC
   ========================================================================== */
.dispatch-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-emerald);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 28px;
}

.dispatch-form-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.step-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.dispatch-form-head h2 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.form-group {
  margin-bottom: 16px;
}

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

.form-label-sm {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control-select,
.form-control-input,
.form-control-textarea {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: var(--text-sm);
  outline: none;
  transition: all 0.15s ease;
}

.form-control-select:focus,
.form-control-input:focus,
.form-control-textarea:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 2px var(--emerald-glow);
}

.form-control-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.advanced-toggle-wrap {
  margin-bottom: 16px;
}

.btn-link-toggle {
  background: transparent;
  border: none;
  color: var(--emerald);
  font-size: var(--text-xs);
  cursor: pointer;
  padding: 0;
  font-weight: 500;
}

.btn-link-toggle:hover {
  text-decoration: underline;
}

.advanced-panel {
  background: var(--bg-panel);
  border: 1px dashed var(--border-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
}

.dispatch-form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.planning-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 500;
  animation: pulse 1.5s infinite;
}

.spinner-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: #38bdf8;
  animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* DANH SÁCH DỰ ÁN */
.project-list-section {
  margin-top: 10px;
}

.section-title-row {
  margin-bottom: 14px;
}

.section-title-row h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-main);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.project-card:hover {
  border-color: var(--border-emerald);
  transform: translateY(-2px);
}

.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.project-card-name {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text-main);
}

.project-card-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 8px;
}

/* ==========================================================================
   MÀN HÌNH 3: MÀN HÌNH PIPELINE (TRỌNG TÂM SƠ ĐỒ LUỒNG NGANG)
   ========================================================================== */
.task-strip-wrap {
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.task-strip-scroll {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}

/* TASKCARD COMPONENT */
.task-strip-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-width: 240px;
  max-width: 280px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.task-strip-card:hover {
  border-color: var(--border-bright);
}

.task-strip-card.active {
  border-color: var(--emerald);
  background: var(--bg-card-active);
  box-shadow: 0 0 14px var(--emerald-glow);
}

.task-strip-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.task-strip-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: #34d399;
}

.task-strip-title {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.task-strip-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.task-strip-progress-val {
  height: 100%;
  background: var(--emerald);
  border-radius: var(--radius-pill);
}

/* PIPELINE WORKSPACE LAYOUT (CANVAS + SLIDE ACTION PANEL) */
.pipeline-workspace-layout {
  display: flex;
  gap: 18px;
  min-width: 0;
  align-items: flex-start;
  min-height: auto;
}

.pipeline-canvas-card {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.pipeline-canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.canvas-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-base);
}

.canvas-header-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* SƠ ĐỒ LUỒNG NGANG PIPELINE */
.pipeline-flow-diagram {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 4px;
}

.pipeline-branch-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.pipeline-arrow {
  color: var(--text-dim);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

/* PIPELINENODE COMPONENT */
.pipeline-node {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  min-width: 112px;
  max-width: 138px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.pipeline-node:hover {
  transform: translateY(-2px);
  border-color: var(--border-bright);
}

.pipeline-node.selected {
  border-color: var(--emerald);
  box-shadow: 0 0 16px var(--emerald-glow);
}

/* CÁC TRẠNG THÁI NODE */
.pipeline-node.node-completed {
  border-color: rgba(16, 185, 129, 0.4);
}

.pipeline-node.node-completed .node-status-icon {
  color: var(--emerald);
}

.pipeline-node.node-running {
  border-color: var(--cyan);
  box-shadow: 0 0 14px var(--cyan-glow);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% { border-color: rgba(56, 189, 248, 0.45); }
  50% { border-color: rgba(56, 189, 248, 1); box-shadow: 0 0 20px rgba(56, 189, 248, 0.4); }
}

.pipeline-node.node-warning {
  border-color: var(--amber);
  box-shadow: 0 0 14px var(--amber-glow);
}

.pipeline-node.node-failed {
  border-color: var(--red);
  box-shadow: 0 0 14px var(--red-glow);
}

.pipeline-node.node-pending {
  opacity: 0.55;
}

.node-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.node-step-title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-main);
}

.node-status-icon {
  font-size: 13px;
}

.node-agent-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.node-agent-avatar {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.node-duration-row {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ACTIONPANEL COMPONENT (SLIDE PANEL BÊN PHẢI) */
.pipeline-action-panel {
  width: 360px;
  max-width: 100%;
  background: var(--bg-frame);
  border: 1px solid var(--border-emerald);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  animation: slideLeft 0.2s ease-out;
  flex-shrink: 0;
}

@keyframes slideLeft {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-step-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

.panel-header h3 {
  font-size: var(--text-base);
  font-weight: 600;
}

.btn-icon-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px;
}

.btn-icon-close:hover {
  color: var(--text-main);
}

.panel-body {
  padding: 18px 20px;
  flex: 1;
  overflow-y: auto;
}

.panel-meta-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.panel-section {
  margin-bottom: 18px;
}

.panel-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.panel-artifacts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-artifact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: #34d399;
}

.panel-log-box {
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  color: #cbd5d0;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.panel-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-footer .btn {
  font-size: 12px;
  padding: 7px 12px;
  white-space: nowrap;
}

.banner-approved-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-sm);
  color: #34d399;
  font-size: 12.5px;
  font-weight: 500;
}

.badge-status-running {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fbbf24;
  font-size: 12px;
  font-weight: 500;
}

.badge-status-failed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #f87171;
  font-size: 12px;
  font-weight: 500;
}

/* ==========================================================================
   MÀN HÌNH 4: AGENT & MÁY TRẠM (FLEET NODES & LIVE TERMINAL)
   ========================================================================== */
.agent-view-modes {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

/* AGENTCARD COMPONENT */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.agent-card:hover {
  border-color: var(--border-card);
}

.agent-card.selected {
  border-color: var(--emerald);
  box-shadow: 0 0 16px var(--emerald-glow);
  background: var(--bg-card-active);
}

.agent-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.agent-card-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-main);
}

.agent-resource-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.resource-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.resource-label {
  width: 32px;
  font-weight: 500;
}

.resource-track {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.resource-fill {
  height: 100%;
  background: var(--emerald);
  border-radius: var(--radius-pill);
}

.resource-fill.fill-cyan { background: var(--cyan); }

.resource-pct {
  font-family: var(--font-mono);
  width: 30px;
  text-align: right;
  color: var(--text-dim);
}

.agent-card-bottom {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* TERMINAL VIEWPORT CARD */
.terminal-stage-card {
  background: var(--bg-terminal);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

.terminal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.terminal-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
}

.terminal-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--emerald);
  box-shadow: 0 0 6px var(--emerald);
}

.terminal-viewport-container {
  min-height: 260px;
  max-height: 380px;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: #e2e8f0;
}

.terminal-viewport-container.grid-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
}

.terminal-grid-pane {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
  height: 180px;
  overflow-y: auto;
}

.terminal-grid-pane-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--emerald);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 4px;
}

.terminal-command-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.terminal-prompt {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--emerald);
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* SUB TABS CONTAINER (AUDIT LOG & TÀI LIỆU) */
.sub-tabs-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.sub-tabs-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.sub-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.sub-tab-btn:hover {
  color: var(--text-main);
}

.sub-tab-btn.active {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.audit-filter-bar {
  margin-bottom: 12px;
}

.input-sm {
  padding: 7px 12px;
  font-size: var(--text-xs);
}

.audit-list-view {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.audit-entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
}

.docs-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.compact-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.compact-item {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: var(--text-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   MÀN HÌNH 5: CÀI ĐẶT
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.settings-card h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 6px;
}

.auth-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.plugins-mini-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.plugin-item-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
}

/* ==========================================================================
   STATUSBADGE & CÁC NÚT BẤM (BUTTONS)
   ========================================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.status-badge.badge-running { background: rgba(127, 166, 196, 0.16); color: var(--info); }
.status-badge.badge-success { background: rgba(157, 191, 142, 0.16); color: var(--success); }
.status-badge.badge-warning { background: rgba(224, 180, 88, 0.16); color: var(--warning); }
.status-badge.badge-danger { background: rgba(224, 112, 95, 0.16); color: var(--danger); }
.status-badge.badge-idle { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-panel);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-primary-emerald {
  background: var(--accent);
  color: #14110F;
  border-color: var(--accent);
}

.btn-primary-emerald:hover {
  background: #EFE4CE;
  color: #14110F;
  box-shadow: 0 0 14px var(--emerald-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-bright);
}

.btn-subtle {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
  background: rgba(245, 158, 11, 0.25);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn.active {
  background: var(--accent);
  color: #14110F;
  border-color: var(--accent);
}

/* ==========================================================================
   TRẠNG THÁI GIAO DIỆN: RỖNG, SKELETON, LỖI
   ========================================================================== */
.empty-state-card {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border-card);
  border-radius: var(--radius-lg);
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.empty-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto 18px auto;
}

/* SKELETON LOADING */
.skeleton-box {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.09) 37%, rgba(255, 255, 255, 0.04) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ==========================================================================
   RESPONSIVE (MOBILE 360PX, 390PX, TABLET, DESKTOP 1280PX)
   ĐẢM BẢO 0PX HORIZONTAL OVERFLOW
   ========================================================================== */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .studio-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 10px 14px;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-item-btn {
    white-space: nowrap;
    padding: 8px 12px;
  }

  .sidebar-bottom {
    display: none;
  }

  .overview-split-layout {
    grid-template-columns: 1fr;
  }

  .kpi-hero-grid {
    grid-template-columns: 1fr 1fr;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .agent-cards-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pipeline-workspace-layout {
    flex-direction: column;
  }

  .pipeline-action-panel {
    width: 100%;
  }

  .docs-split-grid,
  .settings-grid,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {
  .agentos-topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .topbar-center-group {
    order: 3;
    max-width: 100%;
    width: 100%;
    margin-top: 6px;
  }

  .kpi-hero-grid {
    grid-template-columns: 1fr;
  }

  .agent-cards-grid {
    grid-template-columns: 1fr;
  }

  .terminal-viewport-container.grid-mode {
    grid-template-columns: 1fr;
  }

  .studio-main {
    padding: 14px 12px;
  }
}

/* =============================================================================
   GIAI ĐOẠN 2: STYLES CHO MODALS, RAW LOG VIEWER & ARTIFACT PREVIEW
   ============================================================================= */

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  width: 100%;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1.2;
  border-radius: 4px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.15));
  color: var(--text-main, #ececec);
  transition: all 0.15s ease;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-bright, rgba(255, 255, 255, 0.3));
}

.badge-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted, #a1a1aa);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* MODAL OVERLAY & CARD */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background: #18181b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card-lg {
  max-width: 960px;
  width: 94vw;
}

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #1f1f23;
}

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

.modal-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #fafafa;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-body-code {
  padding: 0;
  max-height: 78vh;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #141416;
}

/* RAW LOG VIEWER & TOOLBAR */
.raw-log-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #111113;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.raw-log-actions {
  display: flex;
  gap: 8px;
}

.raw-log-viewer {
  margin: 0;
  padding: 16px;
  background: #09090b;
  color: #22c55e;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 520px;
  overflow-y: auto;
  border-radius: 0;
}

.artifact-preview-container {
  margin: 0;
  padding: 18px;
  background: #09090b;
  color: #e4e4e7;
  font-family: "JetBrains Mono", "Inter", sans-serif;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
}

/* ARTIFACT ITEMS IN ACTION PANEL */
.panel-artifact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  margin-bottom: 6px;
  gap: 8px;
}

.artifact-path-label {
  font-size: 12px;
  color: #d4d4d8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ARTIFACT VISUAL PREVIEW & MARKDOWN CONTAINER */
.artifact-tab-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.artifact-visual-frame-wrap {
  width: 100%;
  background: #121110;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.artifact-live-iframe {
  width: 100%;
  height: 560px;
  border: none;
  background: #121110;
}

.artifact-markdown-container {
  padding: 24px;
  background: #181716;
  color: #e6d9bf;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  max-height: 560px;
  overflow-y: auto;
}

.artifact-markdown-container h1,
.artifact-markdown-container h2,
.artifact-markdown-container h3 {
  color: #f59e0b;
  margin-top: 18px;
  margin-bottom: 8px;
  font-weight: 600;
}

.artifact-markdown-container table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

.artifact-markdown-container th,
.artifact-markdown-container td {
  border: 1px solid rgba(230, 217, 191, 0.15);
  padding: 8px 12px;
  text-align: left;
}

.artifact-markdown-container th {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.artifact-markdown-container code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: #34d399;
}

.artifact-markdown-container pre {
  background: #09090b;
  padding: 14px;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   PHASE 3: BENTO PRO, KANBAN BOARD MULTI-VIEW & SMART STATUS FILTERS
   ========================================================================== */
.pipeline-toolbar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pipeline-filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}

.pipeline-filter-pills::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.filter-pill:hover {
  background: rgba(230, 217, 191, 0.08);
  color: var(--text-main);
  border-color: var(--border-bright);
}

.filter-pill.active {
  background: rgba(230, 217, 191, 0.15);
  border-color: var(--accent);
  color: #faf5ee;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(230, 217, 191, 0.12);
}

.pill-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-muted);
}

.filter-pill.active .pill-counter {
  background: var(--accent);
  color: #14110f;
  font-weight: 700;
}

.view-mode-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.view-mode-toggle .btn {
  font-size: 12px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
}

.view-mode-toggle .btn.active {
  background: var(--surface-2);
  border-color: var(--border-bright);
  color: #faf5ee;
  font-weight: 600;
}

/* KANBAN BOARD CONTAINER & COLUMNS */
.kanban-board-container {
  width: 100%;
  margin-top: 4px;
}

.kanban-columns-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: flex-start;
}

.kanban-col {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  transition: border-color 0.15s;
}

.kanban-col:hover {
  border-color: var(--border-bright);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.kanban-col-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
}

.kanban-col-dot.dot-queued {
  background: var(--text-dim);
}

.kanban-col-dot.dot-running {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

.kanban-col-dot.dot-warning {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}

.kanban-col-dot.dot-approved {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald-glow);
}

.kanban-col-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-main);
}

.kanban-col-count {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
}

.kanban-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.kanban-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.kanban-card.selected {
  border-color: var(--emerald);
  box-shadow: 0 0 12px var(--emerald-glow);
}

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

.kanban-card-id {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
}

.kanban-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.4;
  word-break: break-word;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 4px;
}

.kanban-card-agent {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.kanban-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.kanban-card-actions .btn {
  font-size: 11px;
  padding: 4px 8px;
}

/* FULLSCREEN LOG BOX & FULLSCREEN MODALS */
.panel-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.panel-log-box.fullscreen {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  max-height: none !important;
  height: calc(100vh - 40px) !important;
  z-index: 1000;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.85);
}

.modal-card.fullscreen {
  width: 96vw !important;
  max-width: 96vw !important;
  height: 94vh !important;
  max-height: 94vh !important;
}

.modal-card.fullscreen .raw-log-viewer,
.modal-card.fullscreen .artifact-visual-frame-wrap,
.modal-card.fullscreen .artifact-markdown-container {
  max-height: 75vh !important;
  height: 75vh !important;
}

/* RESPONSIVE LAYOUT CHỐNG TRÀN NGANG */
@media (max-width: 992px) {
  .kanban-columns-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .kanban-columns-grid {
    grid-template-columns: 1fr;
  }
  .pipeline-toolbar-card {
    flex-direction: column;
    align-items: stretch;
  }
  .view-mode-toggle {
    justify-content: center;
  }
}

/* ==========================================================================
   AGENTOS V3: TOPBAR PROFILE & AUTH MODAL
   ========================================================================== */
#viewer-role-chip.clickable {
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

#viewer-role-chip.clickable:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

.topbar-avatar-initial {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s;
}

.topbar-avatar-initial:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

/* ==========================================================================
   AGENTOS V3: LIVING SVG DAG CANVAS COMPONENT
   ========================================================================== */
.dag-canvas-section {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.dag-toolbar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.dag-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dag-legend-line {
  display: inline-block;
  width: 22px;
  height: 3px;
  border-radius: 2px;
}

.dag-legend-line.crit-line {
  background: #fbbf24;
}

.dag-legend-line.flow-line {
  background: #34d399;
}

.dag-legend-line.share-line {
  background: #f87171;
  border-top: 2px dashed #f87171;
  height: 0;
}

.dag-legend-box.gate-box {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #a78bfa;
  border-radius: 2px;
  background: rgba(167, 139, 250, 0.15);
}

.dag-zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dag-zoom-val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 44px;
  text-align: center;
}

.dag-canvas-scrollbox {
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow: auto;
  min-height: 480px;
  max-height: 620px;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.dag-svg-canvas {
  display: block;
  user-select: none;
  min-width: 760px;
  overflow: visible;
}

/* ĐỒ THỊ DAG: ĐƯỜNG NỐI (EDGES) */
.dag-edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 2px;
  transition: stroke 0.2s, stroke-width 0.2s;
}

.dag-edge.crit {
  stroke: #fbbf24;
  stroke-width: 2.8px;
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.45));
}

.dag-edge.flow {
  stroke: #34d399;
  stroke-width: 2.5px;
  stroke-dasharray: 7 5;
  animation: planDash 1.2s linear infinite;
  filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.45));
}

.dag-edge.share {
  stroke: #f87171;
  stroke-dasharray: 4 4;
  stroke-width: 1.6px;
  opacity: 0.85;
}

@keyframes planDash {
  to {
    stroke-dashoffset: -24;
  }
}

/* ĐỒ THỊ DAG: NÚT (NODES) */
.dag-node-group {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.dag-node-group:hover {
  filter: brightness(1.15);
}

.dag-node-rect {
  rx: 8px;
  fill: var(--bg-card);
  stroke: var(--border-subtle);
  stroke-width: 1.5px;
  transition: all 0.2s ease;
}

.dag-node-group.active .dag-node-rect {
  stroke: var(--cyan);
  stroke-width: 2.2px;
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.5));
}

.dag-node-group.completed .dag-node-rect {
  stroke: rgba(16, 185, 129, 0.6);
}

.dag-node-group.failed .dag-node-rect {
  stroke: var(--red);
  stroke-width: 2px;
  filter: drop-shadow(0 0 8px rgba(248, 113, 113, 0.45));
}

.dag-node-group.gate .dag-node-rect {
  stroke: #a78bfa;
  stroke-dasharray: 5 3;
}

.dag-node-group.critical .dag-node-rect {
  stroke: #fbbf24;
}

.dag-node-group.selected .dag-node-rect {
  stroke: var(--emerald);
  stroke-width: 2.5px;
  filter: drop-shadow(0 0 12px var(--emerald-glow));
}

.dag-halo {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 3px;
  opacity: 0.6;
  animation: planHalo 2s ease-in-out infinite;
}

@keyframes planHalo {
  0%, 100% {
    r: 12px;
    opacity: 0.25;
  }
  50% {
    r: 18px;
    opacity: 0.8;
  }
}

.dag-node-title {
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--text-main);
  pointer-events: none;
}

.dag-node-id {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--text-dim);
  pointer-events: none;
}

.dag-node-badge {
  font-size: 9.5px;
  font-weight: 600;
  pointer-events: none;
}

/* ==========================================================================
   AGENTOS V3: KNOWLEDGE BASE & FILE NOTES COMPONENT
   ========================================================================== */
.knowledge-toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card);
}

.knowledge-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.knowledge-search-wrap .search-icon {
  font-size: 14px;
  color: var(--text-dim);
  user-select: none;
}

.knowledge-search-wrap input {
  flex: 1;
  background: var(--bg-panel);
}

.knowledge-category-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.knowledge-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.knowledge-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-card);
}

.knowledge-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

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

.cat-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cat-badge.cat-risk {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.cat-badge.cat-lesson {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.cat-badge.cat-error_fix {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.cat-badge.cat-pattern {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.cat-badge.cat-decision {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.knowledge-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
}

.knowledge-card-body {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 96px;
  overflow-y: auto;
}

.knowledge-files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.knowledge-file-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-panel);
  color: #34d399;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.knowledge-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.knowledge-tag {
  font-size: 11px;
  color: var(--text-dim);
}

.knowledge-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
  margin-top: 2px;
}

/* ==========================================================================
   AGENTOS V3: BẢO VỆ CHỐNG TRÀN NGANG TOÀN DIỆN CHO MOBILE (360PX & 390PX)
   ========================================================================== */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

.app-container, .main-content-layout {
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .knowledge-cards-grid {
    grid-template-columns: 1fr;
  }
  .knowledge-toolbar-card {
    padding: 12px;
  }
  .knowledge-search-wrap {
    flex-direction: column;
    align-items: stretch;
  }
  .modal-card {
    max-width: calc(100vw - 24px) !important;
    margin: 12px;
  }
  .form-row-2col {
    grid-template-columns: 1fr !important;
  }
  .dag-toolbar-card {
    flex-direction: column;
    align-items: stretch;
  }
  .dag-legend-list {
    font-size: 10.5px;
    gap: 10px;
  }
}


