/* ============================================================
   Components: cards, kpis, tables, buttons, forms, charts
   ============================================================ */

/* ==== Card ==== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--duration-fast) var(--ease-out);
}

.card.elevated:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ==== KPI ==== */
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.kpi:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi.primary {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--accent-dim) 100%);
  border-color: var(--accent-2);
}

.kpi .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .value.info { color: var(--info); }
.kpi .value.warn { color: var(--warning); }
.kpi .value.danger { color: var(--danger); }
.kpi .value.success { color: var(--success); }
.kpi .value.purple { color: var(--purple); }
.kpi .value.pink { color: var(--pink); }
.kpi .value.muted { color: var(--text-secondary); }

.kpi .sub { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.kpi .delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}
.kpi .delta.up { background: var(--success-dim); color: var(--success); }
.kpi .delta.down { background: var(--danger-dim); color: var(--danger); }
.kpi .delta.flat { background: var(--bg-card-2); color: var(--text-muted); }

.kpi .spark {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  opacity: 0.5;
  pointer-events: none;
}

/* ==== Grid ==== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ==== Button ==== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover { background: var(--bg-card-3); border-color: var(--border-hover); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  color: var(--brand-on-accent);
  border-color: var(--accent);
}
.btn.primary:hover {
  background: var(--brand-accent-deep);
  box-shadow: var(--shadow-accent);
  color: var(--brand-on-accent);
}

.btn.danger { background: var(--danger); color: #0F0F11; border-color: var(--danger); }
.btn.danger:hover { background: #EF4444; }
.btn.warn { background: var(--warning); color: #0F0F11; border-color: var(--warning); }
.btn.warn:hover { background: #F59E0B; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-card-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.lg { padding: 12px 20px; font-size: 14px; }

/* ==== Table ==== */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-2);
}

table { width: 100%; border-collapse: collapse; }
th {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  text-align: inherit;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-2);
  position: sticky;
  top: 0;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--duration-fast); }
tbody tr:hover { background: var(--bg-card-2); }

/* ==== Pill / Badge ==== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.pill.default { background: var(--accent); color: var(--brand-on-accent); }
.pill.ok { background: var(--success-dim); color: var(--success); }
.pill.warn { background: var(--warning-dim); color: var(--warning); }
.pill.err { background: var(--danger-dim); color: var(--danger); }
.pill.idle { background: var(--bg-card-2); color: var(--text-muted); }
.pill.info { background: var(--info-dim); color: var(--info); }
.pill.purple { background: var(--purple-dim); color: var(--purple); }
.pill.pink { background: var(--pink-dim); color: var(--pink); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok .dot { animation: pulse 2s ease-in-out infinite; }

/* ==== Activity dot (P2 #4) ====
   Inline dot in agent name cells. Distinct from .pill .dot (which is the
   gateway status indicator). This one shows "is the agent actually doing
   something" — a separate concept from connection state. */
.activity-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bg-primary);
  margin-inline-end: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}
.activity-dot.active {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
}
.activity-dot.recent {
  background: var(--warning);
}
.activity-dot.idle,
.activity-dot.never {
  background: var(--text-faint);
}

/* ==== Form ==== */
input, textarea, select {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  transition: all var(--duration-fast) var(--ease-out);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

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

.form-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 200px; }

textarea { resize: vertical; min-height: 80px; font-family: var(--font-mono); font-size: 12px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238A8A93' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-inline-start: 36px;
}
[dir="rtl"] select {
  background-position: right 12px center;
}

/* ==== Search ==== */
.search-box { position: relative; }
.search-box .icon {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
}
[dir="rtl"] .search-box .icon { left: 12px; right: auto; }
.search-box input { padding-inline-end: 36px; }
[dir="rtl"] .search-box input { padding-inline-end: 12px; padding-inline-start: 36px; }

.search-box .clear {
  position: absolute;
  inset-inline-start: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card-2);
  border: none;
  color: var(--text-muted);
  width: 20px; height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.search-box.has-value .clear { display: inline-flex; }
.search-box .clear:hover { background: var(--bg-card-3); color: var(--text-primary); }

/* ==== Tabs ==== */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-card-2);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  white-space: nowrap;
  transition: all var(--duration-fast);
  font-family: inherit;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ==== Chip Filter ==== */
.dept-tab {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-card-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--duration-fast);
  white-space: nowrap;
  font-family: inherit;
}
.dept-tab:hover { color: var(--text-primary); border-color: var(--border-hover); }
.dept-tab.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ==== Empty state ==== */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; opacity: 0.3; margin-bottom: 12px; }
.empty-state .title { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }
.empty-state .desc { font-size: 12px; }

/* ==== Section title ==== */
.section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
.section-title .badge {
  background: var(--bg-card-2);
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}

/* ==== Tooltip ==== */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-3);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  white-space: nowrap;
  z-index: var(--z-tooltip);
  pointer-events: none;
  animation: fadeIn 0.15s ease;
}

/* ==== Toast ==== */
.toast-container {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideIn var(--duration-base) var(--ease-out);
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.err { border-inline-start-color: var(--danger); }
.toast.warn { border-inline-start-color: var(--warning); }
.toast.info { border-inline-start-color: var(--info); }
.toast .title { font-weight: 700; color: var(--text-primary); }
.toast .msg { color: var(--text-muted); font-size: 12px; }

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

/* ==== Modal ==== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--duration-fast);
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 64px);
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeIn var(--duration-base) var(--ease-out);
  position: relative;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-card-2);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  border: none;
}
.modal-close:hover { background: var(--bg-card-3); color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ==== Drawer ==== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-drawer);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; bottom: 0;
  inset-inline-end: 0;
  width: 480px;
  max-width: 100vw;
  background: var(--bg-card);
  border-inline-start: 1px solid var(--border);
  z-index: calc(var(--z-drawer) + 1);
  transform: translateX(100%);
  transition: transform var(--duration-base) var(--ease-out);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
[dir="rtl"] .drawer { transform: translateX(-100%); }
.drawer.open { transform: translateX(0) !important; }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}
.drawer-body { padding: 20px; }

/* ==== Chart ==== */
.chart-container {
  position: relative;
  width: 100%;
  height: 200px;
}
.chart-container.tall { height: 280px; }

.sparkline {
  width: 100%;
  height: 100%;
  display: block;
}

.donut-chart {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto;
}
.donut-chart svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-chart .center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.donut-chart .center .value { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.donut-chart .center .label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ==== Price card (Market Intel) ==== */
.price-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all var(--duration-fast);
  position: relative;
  overflow: hidden;
}
.price-card:hover { border-color: var(--border-hover); }
.price-card .symbol {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}
.price-card .symbol-icon {
  width: 32px; height: 32px;
  background: var(--accent-dim);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--accent);
  font-weight: 800;
}
.price-card .price {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.price-card .change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}
.price-card .change.up { color: var(--success); }
.price-card .change.down { color: var(--danger); }
.price-card .change.flat { color: var(--text-muted); }

.price-card .meta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* ==== Activity feed ==== */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-item .icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.activity-item .icon.ok { background: var(--success-dim); color: var(--success); }
.activity-item .icon.warn { background: var(--warning-dim); color: var(--warning); }
.activity-item .icon.err { background: var(--danger-dim); color: var(--danger); }
.activity-item .icon.info { background: var(--info-dim); color: var(--info); }
.activity-item .icon.purple { background: var(--purple-dim); color: var(--purple); }
.activity-item .body { flex: 1; min-width: 0; }
.activity-item .title { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.activity-item .time { color: var(--text-muted); font-size: 10px; margin-top: 2px; }

/* ==== Email card (Google Workspace) ==== */
.email-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.email-item:hover { background: var(--bg-card-2); }
.email-item.unread { background: var(--accent-dim); }
.email-item .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card-3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.email-item .body { flex: 1; min-width: 0; }
.email-item .from { font-weight: 700; font-size: 13px; color: var(--text-primary); }
.email-item .subject { font-size: 13px; color: var(--text-primary); margin-top: 2px; }
.email-item .summary { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.email-item .time { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

/* ==== Content card (Content Studio) ==== */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--duration-fast);
}
.content-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.content-card .thumb {
  height: 120px;
  background: linear-gradient(135deg, var(--accent-dim), var(--purple-dim));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  color: var(--accent);
}
.content-card .info { padding: 12px 14px; }
.content-card .title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.content-card .meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ==== Loading skeleton ==== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card-2) 0%, var(--bg-card-3) 50%, var(--bg-card-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ============================================================
   M2 ADDITIONS — VEGA v3.0 components
   Added 2026-06-17. Do NOT remove or rename — M3-M6 depend on these.
   ============================================================ */

/* === Glassmorphism card === */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card-lg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  padding: 20px;
  transition: all var(--duration-base) var(--ease-out);
}
.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  border-color: var(--border-hover);
}
[data-theme="light"] .glass-card {
  background: var(--glass-bg-light);
  border-color: var(--glass-border-light);
  box-shadow: var(--glass-shadow-light);
}

/* === Avatar === */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-family: var(--font-arabic);
  position: relative;
  flex-shrink: 0;
  user-select: none;
  background: var(--bg-card-2);
  color: var(--text-primary);
  border: 2px solid var(--bg-card-3);
}
.avatar-xs { width: var(--avatar-xs); height: var(--avatar-xs); font-size: 10px; }
.avatar-sm { width: var(--avatar-sm); height: var(--avatar-sm); font-size: 12px; }
.avatar-md { width: var(--avatar-md); height: var(--avatar-md); font-size: 16px; }
.avatar-lg { width: var(--avatar-lg); height: var(--avatar-lg); font-size: 22px; }
.avatar-xl { width: var(--avatar-xl); height: var(--avatar-xl); font-size: 32px; }
.avatar-2xl { width: var(--avatar-2xl); height: var(--avatar-2xl); font-size: 48px; }

.avatar-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 25%;
  height: 25%;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  background: var(--status-idle);
}
.avatar-status-dot.active { background: var(--status-active); box-shadow: 0 0 8px var(--status-active); }
.avatar-status-dot.thinking { background: var(--status-thinking); animation: pulse 1.5s infinite; }
.avatar-status-dot.error { background: var(--status-error); }
.avatar-status-dot.streaming { background: var(--status-streaming); animation: pulse 1s infinite; }

/* === Status pill === */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-card-3);
  color: var(--text-muted);
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.active { background: var(--success-dim); color: var(--success); }
.status-pill.idle { background: var(--bg-card-3); color: var(--text-muted); }
.status-pill.error { background: var(--danger-dim); color: var(--danger); }
.status-pill.thinking { background: rgba(167, 139, 250, 0.15); color: var(--purple); }
.status-pill.streaming { background: var(--info-dim); color: var(--info); }

/* === Event card === */
.event-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card-lg);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: all var(--duration-base) var(--ease-out);
  border-right: 3px solid var(--accent-ops);
  position: relative;
  overflow: hidden;
}
[dir="rtl"] .event-card { border-right: none; border-left: 3px solid var(--accent-ops); }
.event-card:hover { background: var(--bg-card-2); transform: translateX(-2px); }
[dir="rtl"] .event-card:hover { transform: translateX(2px); }
.event-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(206, 253, 130, 0.05) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}
.event-card:hover::after { opacity: 1; }

.event-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.event-content { flex: 1; min-width: 0; }
.event-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.event-desc { font-size: 12px; color: var(--text-muted); }
.event-time { font-size: 10px; color: var(--text-faint); font-family: var(--font-mono); margin-top: 4px; }

/* === Chat bubble === */
.chat-bubble {
  max-width: var(--chat-bubble-max-width);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: bubbleIn var(--duration-base) var(--ease-spring);
}
.chat-bubble.user {
  background: var(--accent);
  color: var(--brand-on-accent);
  border-bottom-right-radius: 4px;
  margin-left: auto;
}
[dir="rtl"] .chat-bubble.user { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; margin-left: 0; margin-right: auto; }
.chat-bubble.assistant {
  background: var(--bg-card-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  margin-right: auto;
}
[dir="rtl"] .chat-bubble.assistant { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; margin-right: 0; margin-left: auto; }
.chat-bubble.thinking {
  background: var(--bg-card-2);
  color: var(--text-muted);
  border: 1px dashed var(--border-hover);
  font-style: italic;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
}
.typing-indicator span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* === Chat drawer (slide-in from right) === */
.chat-drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-drawer);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out);
}
.chat-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.chat-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--drawer-width);
  max-width: 100vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: calc(var(--z-drawer) + 1);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.4);
}
[dir="rtl"] .chat-drawer { right: auto; left: 0; transform: translateX(-100%); border-left: none; border-right: 1px solid var(--border); box-shadow: 16px 0 40px rgba(0, 0, 0, 0.4); }
.chat-drawer.open { transform: translateX(0); }

.chat-drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-drawer-header h3 { font-size: 15px; font-weight: 700; margin: 0; }
.chat-drawer-close {
  margin-right: auto;
  background: transparent; border: 0; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: 6px;
}
[dir="rtl"] .chat-drawer-close { margin-right: 0; margin-left: auto; }
.chat-drawer-close:hover { color: var(--text-primary); background: var(--bg-card-2); }

.chat-drawer-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-drawer-input {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.chat-drawer-input input {
  flex: 1;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-base);
}
.chat-drawer-input input:focus { outline: none; border-color: var(--accent); }
.chat-drawer-input button {
  background: var(--accent);
  color: var(--brand-on-accent);
  border: 0; border-radius: 8px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
}

/* === Action button (write op trigger) === */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out);
  text-decoration: none;
  font-family: var(--font-base);
}
.action-btn:hover {
  background: var(--bg-card-3);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.action-btn.primary {
  background: var(--accent);
  color: var(--brand-on-accent);
  border-color: var(--accent);
}
.action-btn.danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: var(--danger);
}
.action-btn-icon { width: 14px; height: 14px; flex-shrink: 0; }

/* === Premium card (gradient highlight) === */
.premium-card {
  position: relative;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius-card-xl);
  padding: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-accent);
}
.premium-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-dim) 0%, transparent 50%);
  pointer-events: none;
  animation: premiumShimmer 3s ease-in-out infinite;
}
@keyframes premiumShimmer {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* === Empty state (M2 enhanced) === */
.empty-state-m2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-m2 .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}
.empty-state-m2 .title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.empty-state-m2 .desc { font-size: 13px; max-width: 360px; }

/* === Shimmer skeleton (M2) === */
.shimmer {
  background: linear-gradient(90deg,
    var(--bg-card) 0%,
    var(--bg-card-2) 50%,
    var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: shimmerSlide 1.5s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmerSlide {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Hero band (gradient per agent) === */
.hero-band {
  position: relative;
  min-height: var(--hero-height-md);
  border-radius: var(--radius-card-xl);
  overflow: hidden;
  padding: 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.hero-band::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top right, var(--accent-dim) 0%, transparent 60%);
  pointer-events: none;
}
.hero-band-content { position: relative; z-index: 1; flex: 1; }
.hero-band-title { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.hero-band-sub { font-size: 14px; color: var(--text-muted); }
.hero-band-glyph {
  font-size: 96px;
  opacity: 0.3;
  position: absolute;
  bottom: -16px;
  left: 16px;
  pointer-events: none;
  line-height: 1;
}
[dir="rtl"] .hero-band-glyph { left: auto; right: 16px; }


/* === M3 ADDITIONS — Sidebar nav + Search palette === */
/* Added 2026-06-17. Do NOT remove or rename. */

.nav-section {
  margin-bottom: 4px;
}
.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  gap: 6px;
}
.nav-section-header:hover { background: var(--bg-card-2); color: var(--text-secondary); }
.nav-section-header .count {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-card-3);
  color: var(--text-faint);
}
.nav-section-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  max-height: 2000px;
  transition: max-height var(--duration-slow) var(--ease-out);
}
.nav-section.collapsed .nav-section-items {
  max-height: 0;
}
.nav-section.collapsed .chevron { transform: rotate(-90deg); }
.chevron { transition: transform var(--duration-base) var(--ease-out); display: inline-block; }

.nav-item-agent {
  position: relative;
  padding-inline-end: 14px;
  border-inline-end: 3px solid transparent;
  transition: all var(--duration-base) var(--ease-out);
}
.nav-item-agent.active {
  border-inline-end-color: var(--accent);
  background: var(--accent-dim);
}
.nav-item-agent:hover { background: var(--bg-card-2); }
.nav-item-agent .accent-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-inline-end: 8px;
  flex-shrink: 0;
}

/* Legacy .nav-item (backward compat — used by old 8 routes in app.js renderNav) */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--duration-base) var(--ease-out);
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: var(--bg-card-2); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.search-palette-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out);
}
.search-palette-backdrop.open { opacity: 1; pointer-events: auto; }

.search-palette {
  position: fixed;
  top: 15vh; left: 50%;
  transform: translateX(-50%) scale(0.95);
  width: 560px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card-xl);
  box-shadow: var(--shadow-lg);
  z-index: calc(var(--z-modal) + 1);
  opacity: 0;
  transition: all var(--duration-base) var(--ease-spring);
}
.search-palette.open { transform: translateX(-50%) scale(1); opacity: 1; }
.search-palette-input {
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-base);
}
.search-palette-input:focus { outline: none; }
.search-palette-input::placeholder { color: var(--text-faint); }
.search-palette-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}
.search-palette-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--duration-base) var(--ease-out);
}
.search-palette-result:hover,
.search-palette-result.selected {
  background: var(--bg-card-2);
}
.search-palette-result-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.search-palette-result-content { flex: 1; min-width: 0; }
.search-palette-result-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.search-palette-result-sub { font-size: 12px; color: var(--text-muted); }
.search-palette-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Topbar search button (M3) */
.topbar-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out);
  min-width: 180px;
}
.topbar-search:hover { border-color: var(--border-hover); color: var(--text-secondary); }
.topbar-search .search-placeholder { flex: 1; text-align: start; }
.topbar-search .search-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--bg-card-3);
  color: var(--text-faint);
  border: 1px solid var(--border);
}
@media (max-width: 640px) {
  .topbar-search { display: none; }
}

