/* ============================================================
   Aestimor Automation — App CSS
   Dark theme, purple accent, internal workflow platform
   ============================================================ */

/* ── Design Tokens ── */
:root {
  --bg-900: #09090b;
  --bg-800: #0f0f11;
  --bg-700: #18181b;
  --bg-600: #1e1e22;
  --bg-500: #27272a;
  --border: #2a2a2e;
  --border-hover: #3f3f46;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-tertiary: #52525b;
  --citrus: #7c3aed;
  --citrus-light: #8b5cf6;
  --citrus-dark: #6d28d9;
  --citrus-glow: rgba(124, 58, 237, 0.12);
  --citrus-glow-strong: rgba(124, 58, 237, 0.22);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.1);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.1);
  --accent: #7c3aed;
  --surface: #18181b;
  --bg: #0f0f11;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.35);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --sidebar-w: 260px;

  /* Phase 3+ aliases — map to existing design tokens */
  --bg-primary: var(--bg-800);
  --bg-secondary: var(--bg-700);
  --bg-hover: var(--bg-600);
  --border-color: var(--border);
  --accent-color: var(--citrus);
  --accent-bg: var(--citrus-glow);
  --accent-border: var(--citrus-dark);
  /* Aestimor platform token aliases — forward compat */
  --aestimor: var(--citrus);
  --aestimor-light: var(--citrus-light);
  --aestimor-dark: var(--citrus-dark);
  --aestimor-glow: var(--citrus-glow);
  --aestimor-glow-strong: var(--citrus-glow-strong);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-900);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Global scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
html { scrollbar-color: var(--border) transparent; scrollbar-width: thin; }
a { color: var(--citrus); text-decoration: none; }
a:hover { color: var(--citrus-light); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--radius-md);
  font-family: var(--font); font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s var(--ease-out), box-shadow 0.25s ease; text-decoration: none;
  position: relative; overflow: hidden; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transform: translateZ(0);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--citrus), var(--citrus-dark)); color: #fff; }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(124,58,237,0.4), 0 0 0 1px rgba(124,58,237,0.1); filter: brightness(1.05); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.98); box-shadow: 0 1px 4px rgba(124,58,237,0.2); filter: brightness(0.95); }
.btn-secondary { background: var(--bg-600); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-hover); background: var(--bg-500); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-secondary:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.btn-danger { background: linear-gradient(135deg, var(--red), #dc2626); color: #fff; }
.btn-danger:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(239,68,68,0.35); filter: brightness(1.05); }
.btn-danger:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-600); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   Inputs
   ============================================================ */
input, textarea, select {
  background: var(--bg-700); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 14px; font-family: var(--font); font-size: 0.9rem; color: var(--text-primary);
  outline: none; transition: border-color 0.25s var(--ease-out), box-shadow 0.3s var(--ease-out), background 0.25s ease, transform 0.2s var(--ease-out);
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--citrus); box-shadow: 0 0 0 3px var(--citrus-glow), 0 2px 8px rgba(124,58,237,0.08); background: rgba(124,58,237,0.02); }
input:hover:not(:focus), textarea:hover:not(:focus), select:hover:not(:focus) { border-color: var(--border-hover); background: var(--bg-600); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; cursor: pointer; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); display: block; margin-bottom: 6px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; transition: all 0.25s var(--ease-out);
  transform: translateZ(0);
}
.card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 1rem; font-weight: 700; }

/* ============================================================
   Auth Layout
   ============================================================ */
.auth-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% 20%, var(--citrus-glow) 0%, transparent 60%);
  position: relative; overflow: hidden;
}
.auth-wrapper::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 30%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 30%, black 20%, transparent 70%);
  pointer-events: none;
}
.auth-wrapper::after {
  content: ''; position: absolute; top: -200px; right: -200px;
  width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,0.06) 0%, transparent 60%);
  pointer-events: none; animation: auth-float 10s ease-in-out infinite;
}
@keyframes auth-float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-20px); }
}
.auth-card {
  background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 48px; width: 100%; max-width: 440px;
  position: relative; z-index: 1;
  animation: auth-card-in 0.6s var(--ease-spring) both;
  box-shadow: var(--shadow-xl);
}
@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-logo { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 32px; }
.auth-logo svg { width: 40px; height: 40px; }
.auth-logo span { font-size: 1.5rem; font-weight: 800; }
.auth-title { text-align: center; margin-bottom: 8px; font-size: 1.3rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 32px; font-size: 0.9rem; }
.auth-form { display: flex; flex-direction: column; gap: 20px; }
.auth-form input { width: 100%; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 0.85rem; color: var(--text-muted); }
.auth-footer a { color: var(--citrus); }
.auth-copyright { text-align: center; margin-top: 20px; font-size: 0.7rem; color: var(--text-muted); opacity: 0.5; }
.auth-error { background: var(--red-bg); border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius-md); padding: 10px 14px; color: var(--red); font-size: 0.85rem; display: none; }
.auth-error.visible { display: block; }

/* ============================================================
   App Shell
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-800); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.sidebar-header {
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-header > svg { width: 32px; height: 32px; }
.sidebar-header > span svg { width: 32px; height: 32px; }
.sidebar-header span { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); padding: 12px 12px 6px;
  display: flex; align-items: center; gap: 6px;
}

/* ── Search Bar ── */
.sidebar-search { padding: 12px 16px 4px; }
.sidebar-search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-700); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 6px 10px; transition: border-color 0.2s, box-shadow 0.2s;
}
.sidebar-search-box:focus-within {
  border-color: var(--citrus); box-shadow: 0 0 0 2px var(--citrus-glow);
}
.sidebar-search-box svg { color: var(--text-muted); flex-shrink: 0; }
.sidebar-search-box input {
  background: none; border: none; outline: none; color: var(--text-primary);
  font-size: 0.82rem; width: 100%; padding: 2px 0;
  font-family: var(--font);
}
.sidebar-search-box input::placeholder { color: var(--text-tertiary); }
.sidebar-search-kbd {
  font-size: 0.65rem; color: var(--text-tertiary); background: var(--bg-600);
  padding: 1px 5px; border-radius: 3px; border: 1px solid var(--border);
  font-family: var(--font-mono); line-height: 1.4;
}
.sidebar-search-results {
  background: var(--bg-700); border: 1px solid var(--border); border-radius: var(--radius-md);
  margin-top: 6px; max-height: 280px; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.search-result-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 0.82rem;
  transition: background 0.15s;
}
.search-result-item:hover { background: var(--bg-600); }
.search-result-icon { flex-shrink: 0; color: var(--text-muted); display: flex; }
.search-result-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.search-result-type { font-size: 0.7rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; flex-shrink: 0; }
.search-no-results { padding: 16px; text-align: center; font-size: 0.82rem; color: var(--text-muted); }

/* ── Collapsible Nav Groups ── */
.nav-group-toggle {
  cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  padding-right: 12px;
  transition: color 0.15s;
}
.nav-group-toggle:hover { color: var(--text-secondary); }
.nav-group-chevron {
  display: inline-flex; width: 14px; height: 14px;
  transform: rotate(-90deg);
  transition: transform 0.25s var(--ease-out);
}
.nav-group-chevron.open { transform: rotate(0deg); }
.nav-group-chevron svg { width: 14px; height: 14px; }
.nav-group-items {
  overflow: hidden; max-height: 500px;
  transition: max-height 0.3s var(--ease-out), opacity 0.25s;
  opacity: 1;
}
.nav-group-items.collapsed { max-height: 0; opacity: 0; }

/* ── Favorites section ── */
.sidebar-favorites-section .sidebar-section-label { color: var(--citrus); }
.sidebar-favorites-empty {
  font-size: 0.75rem; color: var(--text-tertiary); padding: 6px 16px;
  font-style: italic;
}

/* ── Sidebar Workspace Tree ── */
.sidebar-ws-loading, .sidebar-ws-empty {
  font-size: 0.78rem; color: var(--text-muted); padding: 6px 12px;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-ws-empty { font-style: italic; }
.ws-nav-item {
  margin-bottom: 1px;
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}
.ws-nav-item.ws-active { background: rgba(124, 58, 237, 0.04); }
.ws-nav-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: var(--radius-md);
  cursor: pointer; user-select: none;
  transition: background 0.15s, color 0.15s;
  color: var(--text-secondary); font-size: 0.84rem;
}
.ws-nav-toggle:hover { background: var(--bg-600); color: var(--text-primary); }
.ws-active .ws-nav-toggle { color: var(--citrus); }
.ws-nav-chevron {
  display: inline-flex; width: 12px; height: 12px; flex-shrink: 0;
  transform: rotate(-90deg);
  transition: transform 0.25s var(--ease-out);
}
.ws-nav-chevron.open { transform: rotate(0deg); }
.ws-nav-chevron svg { width: 12px; height: 12px; }
.ws-nav-icon { display: inline-flex; flex-shrink: 0; }
.ws-nav-name {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600; cursor: pointer;
  transition: color 0.15s;
}
.ws-nav-name:hover { color: var(--citrus); }
.ws-nav-star {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--text-tertiary); display: flex; flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s, color 0.15s, transform 0.2s;
  border-radius: 3px;
}
.ws-nav-toggle:hover .ws-nav-star { opacity: 1; }
.ws-nav-star:hover { color: var(--citrus); transform: scale(1.2); }
.ws-subnav {
  overflow: hidden; max-height: 200px;
  transition: max-height 0.3s var(--ease-out), opacity 0.25s;
  opacity: 1; padding-left: 18px;
}
.ws-subnav.collapsed { max-height: 0; opacity: 0; }
.ws-sub-item {
  font-size: 0.8rem !important; padding: 5px 10px !important;
  gap: 8px !important; color: var(--text-muted) !important;
}
.ws-sub-item:hover { color: var(--text-primary) !important; }
.ws-sub-item.active { color: var(--citrus) !important; }
.ws-sub-count {
  margin-left: auto; font-size: 0.68rem; color: var(--text-tertiary);
  background: var(--bg-600); padding: 1px 6px; border-radius: 8px;
  font-weight: 600; min-width: 18px; text-align: center;
}
.nav-item-action {
  font-size: 0.8rem !important; color: var(--text-muted) !important;
  gap: 6px !important; padding: 5px 10px !important;
  border: 1px dashed var(--border) !important; margin: 4px 0 !important;
  transition: all 0.2s var(--ease-out) !important;
}
.nav-item-action:hover {
  color: var(--citrus) !important; border-color: var(--citrus) !important;
  background: var(--citrus-glow) !important;
}

.nav-item-fav {
  padding: 6px 12px; font-size: 0.82rem; gap: 8px;
}
.nav-fav-name {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-fav-remove {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--text-tertiary); border-radius: 3px; display: flex;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.nav-item-fav:hover .nav-fav-remove { opacity: 1; }
.nav-fav-remove:hover { color: var(--red); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s var(--ease-out); position: relative; margin-bottom: 2px;
  -webkit-user-select: none; user-select: none;
  transform: translateZ(0);
}
.nav-item:hover { background: var(--bg-600); color: var(--text-primary); transform: translateX(2px); }
.nav-item:active { transform: scale(0.97); }
.nav-item.active { background: var(--citrus-glow); color: var(--citrus); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--citrus);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; background: var(--citrus); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; }

/* Sidebar footer */
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--citrus-glow);
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700;
  color: var(--citrus); flex-shrink: 0; border: 1px solid rgba(124,58,237,0.15);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.sidebar-user:hover .sidebar-avatar {
  box-shadow: 0 0 16px var(--citrus-glow-strong);
  transform: scale(1.06);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.72rem; color: var(--text-muted); text-transform: capitalize; }
.sidebar-copyright { font-size: 0.65rem; color: var(--text-muted); text-align: center; margin-top: 12px; opacity: 0.6; }

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
/* Smooth page crossfade */
.main-fade-in {
  animation: mainFadeIn 0.4s var(--ease-out) forwards;
}
@keyframes mainFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-body { flex: 1; }
@keyframes content-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Breadcrumb */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  padding: 16px 32px 0; font-size: 0.82rem; color: var(--text-muted);
}
.breadcrumb a { color: var(--text-secondary); transition: color 0.15s; }
.breadcrumb a:hover { color: var(--citrus); }
.breadcrumb-sep { color: var(--text-tertiary); font-size: 0.7rem; }
.breadcrumb-current { color: var(--text-primary); font-weight: 600; }

/* Page header */
.page-header {
  padding: 20px 32px 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
}
.page-header > div:first-child { flex: 1; min-width: 200px; }
.page-header-text { flex: 1; min-width: 200px; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.02em; }
.page-header p { color: var(--text-muted); font-size: 0.88rem; line-height: 1.5; }
.page-header .page-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.02em; }
.page-header .page-subtitle { color: var(--text-muted); font-size: 0.88rem; line-height: 1.5; }
.page-header-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.page-body { padding: 24px 32px 32px; }

/* ============================================================
   Stats Row / Stat Cards
   ============================================================ */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px;
  transition: all 0.25s var(--ease-out); position: relative; overflow: hidden;
  transform: translateZ(0);
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--citrus), var(--citrus-light));
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.4s var(--ease-out);
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.stat-card:hover::before { transform: scaleX(1); }
.stat-card:hover .stat-value { transform: scale(1.03); }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; margin: 4px 0; line-height: 1.1; transition: transform 0.3s var(--ease-out), color 0.3s; }
.stat-card .stat-sub { font-size: 0.8rem; color: var(--text-secondary); transition: color 0.3s; }
.stat-card:hover .stat-sub { color: var(--text-primary); }
.stat-card.accent .stat-value { color: var(--citrus); }
.stat-card.accent { border-color: rgba(124,58,237,0.15); }

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

/* ============================================================
   Workspace & Flow Cards
   ============================================================ */
.workspace-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.workspace-card {
  cursor: pointer; position: relative; overflow: hidden;
  transition: all 0.25s var(--ease-out);
}
.workspace-card::after {
  content: ''; position: absolute; inset: -1px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(124,58,237,0.12), transparent 50%);
  opacity: 0; transition: opacity 0.3s ease; z-index: 0;
}
.workspace-card:hover { border-color: rgba(124,58,237,0.4); transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.25), 0 0 0 1px rgba(124,58,237,0.1); }
.workspace-card:hover::after { opacity: 1; }
.workspace-card:active { transform: translateY(-1px) scale(0.995); }
.workspace-card > * { position: relative; z-index: 1; }

/* ── Card star (favorite) button ── */
.card-star {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--text-tertiary); border-radius: 4px;
  opacity: 0; transition: opacity 0.15s, color 0.15s, transform 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.card:hover .card-star { opacity: 1; }
.card-star:hover { color: var(--citrus); transform: scale(1.2); }
.card-star:active { transform: scale(0.95); }
.ws-name { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.ws-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5; }
.ws-stats { display: flex; gap: 16px; }
.ws-stat { font-size: 0.8rem; color: var(--text-secondary); }
.ws-stat strong { color: var(--citrus); font-weight: 700; }

.flow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.flow-card { cursor: pointer; position: relative; transition: all 0.25s var(--ease-out); }
.flow-card:hover { border-color: rgba(124,58,237,0.4); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.flow-card:active { transform: translateY(-1px) scale(0.995); }
.flow-name { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.flow-type { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; }
.flow-meta { display: flex; gap: 12px; font-size: 0.8rem; color: var(--text-secondary); }
.flow-status { position: absolute; top: 16px; right: 16px; padding: 4px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.flow-status.draft { background: var(--bg-500); color: var(--text-muted); }
.flow-status.deployed { background: var(--green-bg); color: var(--green); }
.flow-status.stopped { background: var(--red-bg); color: var(--red); }

/* ============================================================
   Section Headers
   ============================================================ */
.section-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.section-header h3 {
  font-size: 0.95rem; font-weight: 700; color: var(--text-primary);
}
.section-header .section-count {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  background: var(--bg-500); padding: 2px 10px; border-radius: 12px;
}
.section-divider {
  height: 1px; margin: 28px 0; position: relative; overflow: hidden;
  background: linear-gradient(90deg, transparent, var(--border), var(--border-hover), var(--border), transparent);
  animation: divider-shimmer 3s ease-in-out infinite;
  background-size: 200% 100%;
}
@keyframes divider-shimmer {
  0%, 100% { background-position: 100% 0; }
  50% { background-position: 0% 0; }
}

/* ============================================================
   Tabs — Refined
   ============================================================ */
.tabs {
  display: flex; gap: 0; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  position: relative; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px; font-size: 0.875rem; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.3s var(--ease-out);
  position: relative; white-space: nowrap; flex-shrink: 0;
}
.tab svg { width: 16px; height: 16px; opacity: 0.6; transition: opacity 0.3s, transform 0.3s var(--ease-out); }
.tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.02); }
.tab:hover svg { opacity: 0.9; transform: scale(1.08); }
.tab.active {
  color: var(--citrus); font-weight: 600;
  border-bottom-color: var(--citrus);
}
.tab.active svg { opacity: 1; color: var(--citrus); }
.tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: var(--citrus); border-radius: 2px 2px 0 0;
  box-shadow: 0 0 8px rgba(124,58,237,0.4);
}
.tab-content {
  animation: tab-content-in 0.3s var(--ease-out);
}
@keyframes tab-content-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Builder
   ============================================================ */
.builder-layout { display: flex; height: calc(100vh - 60px); }
.builder-topbar {
  height: 60px; background: var(--bg-800); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
}
.builder-topbar-left { display: flex; align-items: center; gap: 16px; }
.builder-topbar-left .back-btn { color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 0.85rem; transition: color 0.15s; }
.builder-topbar-left .back-btn:hover { color: var(--citrus); }
.builder-topbar-left .flow-title { font-size: 1rem; font-weight: 700; }
.builder-topbar-right { display: flex; align-items: center; gap: 12px; }
.save-indicator { font-size: 0.78rem; color: var(--text-muted); }

/* Palette */
.builder-palette {
  width: 260px; background: var(--bg-800); border-right: 1px solid var(--border);
  overflow-y: auto; flex-shrink: 0;
}
.palette-header { padding: 16px; font-size: 0.82rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid var(--border); }
.palette-section { padding: 8px; }
.palette-section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: 8px 8px 4px; }
.palette-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md);
  cursor: grab; transition: all var(--transition); border: 1px solid transparent; margin-bottom: 2px;
}
.palette-item:hover { background: var(--bg-600); border-color: var(--border); }
.palette-item.dragging { opacity: 0.5; }
.palette-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.palette-icon svg { width: 18px; height: 18px; }
.palette-icon.route { background: var(--citrus-glow); color: var(--citrus); }
.palette-icon.action { background: var(--blue-bg); color: var(--blue); }
.palette-icon.condition { background: var(--yellow-bg); color: var(--yellow); }
.palette-icon.display { background: var(--green-bg); color: var(--green); }
.palette-icon.data { background: rgba(168,85,247,0.1); color: #a855f7; }
.palette-item-text .palette-item-name { font-size: 0.85rem; font-weight: 600; }
.palette-item-text .palette-item-desc { font-size: 0.72rem; color: var(--text-muted); }

/* Canvas */
.builder-canvas {
  flex: 1; background: var(--bg-900); overflow: auto; position: relative;
  background-image: radial-gradient(circle, var(--bg-500) 1px, transparent 1px);
  background-size: 24px 24px;
}
.canvas-inner { width: 4000px; height: 3000px; position: relative; }

/* Nodes */
.flow-node {
  position: absolute; background: var(--bg-800); border: 2px solid var(--border); border-radius: var(--radius-lg);
  padding: 0; min-width: 200px; cursor: move; transition: border-color 0.15s, box-shadow 0.15s;
  user-select: none; z-index: 10;
}
.flow-node:hover { border-color: var(--border-hover); }
.flow-node.selected { border-color: var(--citrus); box-shadow: 0 0 0 3px var(--citrus-glow); }
.flow-node.dragging { z-index: 100; opacity: 0.9; }
.node-header { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.node-type-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.node-type-dot.route { background: var(--citrus); }
.node-type-dot.action { background: var(--blue); }
.node-type-dot.condition { background: var(--yellow); }
.node-type-dot.display { background: var(--green); }
.node-type-dot.data { background: #a855f7; }
.node-title { font-size: 0.82rem; font-weight: 700; }
.node-body { padding: 10px 14px; }
.node-field { margin-bottom: 8px; }
.node-field label { font-size: 0.72rem; margin-bottom: 2px; }
.node-field input, .node-field select { width: 100%; padding: 6px 10px; font-size: 0.8rem; }
.node-port {
  width: 12px; height: 12px; border-radius: 50%; background: var(--bg-500); border: 2px solid var(--border-hover);
  position: absolute; cursor: crosshair; z-index: 20; transition: all 0.15s;
}
.node-port:hover { background: var(--citrus); border-color: var(--citrus); transform: scale(1.3); }
.node-port.port-in { top: 50%; left: -7px; transform: translateY(-50%); }
.node-port.port-out { top: 50%; right: -7px; transform: translateY(-50%); }
.node-port.port-out:hover { transform: translateY(-50%) scale(1.3); }
.node-port.port-in:hover { transform: translateY(-50%) scale(1.3); }

/* Edges */
.edges-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.edges-layer path { stroke: var(--border-hover); stroke-width: 2; fill: none; pointer-events: stroke; cursor: pointer; }
.edges-layer path:hover { stroke: var(--citrus); stroke-width: 3; }

/* Properties panel */
.builder-properties {
  width: 300px; background: var(--bg-800); border-left: 1px solid var(--border);
  overflow-y: auto; flex-shrink: 0; display: none;
}
.builder-properties.open { display: block; }
.props-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.props-title { font-size: 0.9rem; font-weight: 700; }
.props-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.props-close:hover { color: var(--text-primary); }
.props-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.props-section { display: block; }
.props-section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 8px; }

/* ============================================================
   Runtime / Andon Display
   ============================================================ */
.andon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.andon-card {
  background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; position: relative; overflow: hidden; transition: all 0.3s var(--ease-out);
}
.andon-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.andon-card.status-ok::before { background: var(--green); }
.andon-card.status-late::before, .andon-card.status-late_backlog::before { background: var(--red); }
.andon-card.status-near_threshold::before { background: var(--yellow); }
.andon-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.andon-card .route-name { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.andon-card .route-count { font-size: 2rem; font-weight: 900; color: var(--citrus); }
.andon-card .route-threshold { font-size: 0.85rem; color: var(--text-muted); }
.andon-card .route-progress { height: 6px; background: var(--bg-500); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.andon-card .route-progress-bar { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.andon-card.status-ok .route-progress-bar { background: var(--green); }
.andon-card.status-late .route-progress-bar, .andon-card.status-late_backlog .route-progress-bar { background: var(--red); }
.andon-card.status-near_threshold .route-progress-bar { background: var(--yellow); }
.andon-card .route-status { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 8px; }
.andon-card .route-status.ok { color: var(--green); }
.andon-card .route-status.late, .andon-card .route-status.late_backlog { color: var(--red); }
.andon-card .route-status.near_threshold { color: var(--yellow); }
.andon-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* Dispatch */
.dispatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.dispatch-card { background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; transition: all 0.3s var(--ease-out); }
.dispatch-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.dispatch-card .dc-route { font-size: 1.5rem; font-weight: 800; }
.dispatch-card .dc-count { font-size: 0.9rem; color: var(--text-secondary); margin: 8px 0 16px; }

/* Events table */
.events-table { width: 100%; border-collapse: collapse; }
.events-table th { text-align: left; padding: 10px 14px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.events-table td { padding: 10px 14px; font-size: 0.85rem; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.events-table tr { transition: background 0.15s; }
.events-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Integrations — Catalog Redesign */
.int-catalog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.int-catalog-title { flex: 1; }
.int-search-bar { flex: 0 0 auto; }
.int-search-input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-700); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 8px 14px; min-width: 240px; transition: border-color 0.2s;
}
.int-search-input-wrap:focus-within { border-color: var(--citrus); box-shadow: 0 0 0 2px var(--citrus-glow); }
.int-search-input-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.int-search-input {
  background: none; border: none; outline: none; color: var(--text-primary);
  font-size: 0.88rem; width: 100%; font-family: inherit;
}
.int-search-input::placeholder { color: var(--text-tertiary); }

/* Category tabs */
.int-category-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.int-cat-tab {
  background: var(--bg-700); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 14px; font-size: 0.78rem; color: var(--text-secondary);
  cursor: pointer; transition: all 0.2s; font-family: inherit; font-weight: 500;
  text-transform: capitalize;
}
.int-cat-tab:hover { border-color: var(--border-hover); color: var(--text-primary); }
.int-cat-tab.active { background: var(--citrus); border-color: var(--citrus); color: #000; font-weight: 600; }

/* Integration Type Cards */
.integrations-catalog-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
}
.int-type-card {
  position: relative; overflow: hidden;
  background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 20px 16px; cursor: pointer;
  transition: all 0.25s var(--ease-out);
  display: flex; flex-direction: column; gap: 12px;
}
.int-type-card-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 3px; opacity: 0.6;
  transition: opacity 0.25s;
}
.int-type-card:hover {
  border-color: var(--border-hover); transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.int-type-card:hover .int-type-card-accent { opacity: 1; }
.int-type-card:hover .int-type-add-hint { opacity: 1; transform: translateX(0); }
.int-type-logo {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.int-type-body { flex: 1; }
.int-type-name { font-size: 1rem; font-weight: 700; margin-bottom: 4px; color: var(--text-primary); }
.int-type-desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.int-type-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.int-type-cat {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; color: var(--citrus); background: var(--citrus-glow);
  padding: 2px 8px; border-radius: 10px;
}
.int-type-ops { font-size: 0.7rem; color: var(--text-tertiary); }
.int-type-ver { font-size: 0.7rem; color: var(--text-tertiary); font-family: var(--font-mono, monospace); }
.int-type-add-hint {
  position: absolute; top: 14px; right: 14px;
  background: var(--citrus); color: #000; border-radius: var(--radius-md);
  padding: 4px 10px; font-size: 0.75rem; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  opacity: 0; transform: translateX(8px); transition: all 0.2s;
}

/* Active integrations row */
.integrations-active-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px;
}
.int-active-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 18px; transition: all 0.2s;
}
.int-active-card:hover { border-color: var(--border-hover); }
.int-active-logo {
  width: 40px; height: 40px; border-radius: var(--radius-md); border: 1px solid;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.int-active-info { flex: 1; min-width: 0; }
.int-active-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.int-active-type { font-size: 0.78rem; color: var(--text-muted); text-transform: capitalize; }
.int-active-actions { flex-shrink: 0; }

/* No results */
.int-no-results .empty-state { padding: 40px 20px; }

/* Legacy grid (keep for other views) */
.integrations-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ============================================================
   Deployment Cards
   ============================================================ */
.deployment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.deployment-card { transition: all 0.25s var(--ease-out); cursor: pointer; }
.deployment-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); border-color: var(--border-hover); }
.deployment-card:active { transform: translateY(-1px) scale(0.995); }
.deployment-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.deployment-flow { font-size: 1rem; font-weight: 700; }
.deployment-meta { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px; }
.deployment-actions { display: flex; gap: 8px; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: modal-bg-in 0.2s ease;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.2s ease;
}
.modal-overlay.modal-exit { opacity: 0; }
.modal-overlay.modal-exit .modal { transform: scale(0.9) translateY(20px); opacity: 0; }
@keyframes modal-bg-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-800); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 32px; width: 100%; max-width: 500px;
  animation: modal-card-in 0.4s var(--ease-spring);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03);
  transition: transform 0.25s var(--ease-out), opacity 0.2s ease;
}
@keyframes modal-card-in {
  from { opacity: 0; transform: scale(0.9) translateY(24px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h2 { font-size: 1.2rem; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--bg-700); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 20px; z-index: 2000; font-size: 0.88rem;
  animation: toast-in 0.5s var(--ease-spring); box-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03);
  max-width: 380px; transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex; align-items: center; gap: 10px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-weight: 500;
}
.toast.toast-exit {
  opacity: 0; transform: translateY(16px) scale(0.92);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(24px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.toast.success { border-color: rgba(34,197,94,0.2); border-left: 3px solid var(--green); }
.toast.success::before { content: '✓'; color: var(--green); font-weight: 700; font-size: 1rem; }
.toast.error { border-color: rgba(239,68,68,0.2); border-left: 3px solid var(--red); }
.toast.error::before { content: '✕'; color: var(--red); font-weight: 700; font-size: 1rem; }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center; padding: 80px 20px;
  animation: content-in 0.5s var(--ease-out);
}
.empty-state svg { width: 64px; height: 64px; color: var(--text-muted); margin-bottom: 20px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; font-weight: 700; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 28px; max-width: 360px; margin-left: auto; margin-right: auto; line-height: 1.6; }

/* ============================================================
   Loading / Spinner
   ============================================================ */
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--citrus); border-radius: 50%; animation: spin 0.7s linear infinite; }
.loading-center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px; gap: 16px; animation: fadeIn 0.3s ease; }
.loading-center .loading-text { font-size: 0.82rem; color: var(--text-muted); animation: breathe 1.5s ease-in-out infinite; }

/* ============================================================
   Badges
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.badge-ok, .badge-running, .badge-deployed { background: var(--green-bg); color: var(--green); }
.badge-late, .badge-stopped, .badge-error { background: var(--red-bg); color: var(--red); }
.badge-draft { background: var(--bg-500); color: var(--text-muted); }
.badge-warning { background: var(--yellow-bg); color: var(--yellow); }
.badge-pending { background: var(--yellow-bg); color: var(--yellow); }
.badge-approved { background: var(--green-bg); color: var(--green); }
.badge-suspended { background: var(--red-bg); color: var(--red); }
.badge-super_admin, .badge-admin { background: var(--citrus-glow); color: var(--citrus); }
.badge-user { background: var(--bg-500); color: var(--text-secondary); }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── Stagger animation utility ── */
.stagger-item {
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  animation: stagger-in 0.45s var(--ease-out) forwards;
}
.stagger-item:nth-child(1) { animation-delay: 0.04s; }
.stagger-item:nth-child(2) { animation-delay: 0.08s; }
.stagger-item:nth-child(3) { animation-delay: 0.12s; }
.stagger-item:nth-child(4) { animation-delay: 0.16s; }
.stagger-item:nth-child(5) { animation-delay: 0.20s; }
.stagger-item:nth-child(6) { animation-delay: 0.24s; }
.stagger-item:nth-child(7) { animation-delay: 0.28s; }
.stagger-item:nth-child(8) { animation-delay: 0.32s; }
.stagger-item:nth-child(9) { animation-delay: 0.36s; }
.stagger-item:nth-child(10) { animation-delay: 0.40s; }
.stagger-item:nth-child(11) { animation-delay: 0.44s; }
.stagger-item:nth-child(12) { animation-delay: 0.48s; }

/* ── Button ripple effect ── */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.25) 10%, transparent 60%);
  transform: scale(0);
  opacity: 0;
  border-radius: inherit;
  transition: none;
}
.btn:active:not(:disabled)::after {
  transform: scale(2.5);
  opacity: 1;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

/* ── Page transition ── */
.page-transition-enter {
  animation: pageEnter 0.35s var(--ease-out) forwards;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Loading skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-700) 25%, var(--bg-600) 37%, var(--bg-700) 63%);
  background-size: 1000px 100%;
  animation: shimmer 2s ease-in-out infinite;
  border-radius: var(--radius-md);
}
.skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.long { width: 90%; }
.skeleton-heading { height: 24px; width: 50%; margin-bottom: 16px; border-radius: 6px; }
.skeleton-card {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-height: 120px;
}
.skeleton-card .skeleton { background: linear-gradient(90deg, var(--bg-700) 25%, var(--bg-600) 50%, var(--bg-700) 75%); background-size: 800px 100%; animation: shimmer 1.5s ease-in-out infinite; }
.skeleton-stat {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.skeleton-circle { width: 36px; height: 36px; border-radius: 50%; }
.skeleton-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* ── Smooth focus ring for accessibility ── */
*:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--citrus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
  transition: outline-offset 0.2s var(--ease-out);
}
:focus-visible:active { outline-offset: 0px; }

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-500); border-radius: 3px; transition: background 0.2s; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ============================================================
   Dashboard Widget Grid
   ============================================================ */
.dash-toolbar { display: flex; gap: 8px; }
.widget-grid {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; padding: 4px 0;
}
.widget-grid.editing .dashboard-widget { outline: 2px dashed var(--border-hover); outline-offset: -2px; }
.dashboard-widget {
  background: var(--bg-600); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; position: relative; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  overflow: hidden; animation: widget-enter 0.5s var(--ease-spring) both;
}
.dashboard-widget:nth-child(1) { animation-delay: 0.05s; }
.dashboard-widget:nth-child(2) { animation-delay: 0.1s; }
.dashboard-widget:nth-child(3) { animation-delay: 0.15s; }
.dashboard-widget:nth-child(4) { animation-delay: 0.2s; }
.dashboard-widget:nth-child(5) { animation-delay: 0.25s; }
.dashboard-widget:nth-child(6) { animation-delay: 0.3s; }
@keyframes widget-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.dashboard-widget:hover { border-color: var(--border-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* Widget controls */
.widget-controls { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; z-index: 5; opacity: 0; transition: opacity 0.2s; }
.dashboard-widget:hover .widget-controls { opacity: 1; }
.widget-ctrl-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-700); color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s;
}
.widget-ctrl-btn:hover { background: var(--bg-500); color: var(--text-primary); }
.widget-ctrl-btn.danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.widget-ctrl-btn svg { width: 14px; height: 14px; }

/* Widget types */
.widget-stat-inner { text-align: center; width: 100%; }
.widget-stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; font-weight: 600; }
.widget-stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.widget-stat-suffix { font-size: 0.9rem; font-weight: 400; margin-left: 2px; opacity: 0.7; }

.widget-chart-inner { width: 100%; height: 100%; display: flex; flex-direction: column; }
.widget-chart-title { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; }
.widget-bars { flex: 1; display: flex; align-items: flex-end; gap: 6px; min-height: 0; }
.widget-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.widget-bar-value { font-size: 0.65rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; line-height: 1; }
.widget-bar { width: 100%; max-width: 36px; background: var(--citrus); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.5s ease; opacity: 0.85; }
.widget-bar-col:hover .widget-bar { opacity: 1; }
.widget-bar-label { font-size: 0.65rem; color: var(--text-muted); margin-top: 4px; text-align: center; }

.widget-list-inner, .widget-events-inner, .widget-summary-inner { width: 100%; height: 100%; display: flex; flex-direction: column; }
.widget-list-title { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; }
.widget-list-items { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.widget-list-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 0.85rem; transition: background 0.15s; }
.widget-list-row:hover { background: var(--bg-500); }
.widget-list-row.clickable { cursor: pointer; }
.widget-list-row svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.widget-list-name { flex: 1; color: var(--text-primary); }
.widget-list-status { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.widget-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.widget-dot.dot-ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.widget-dot.dot-warning { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.widget-dot.dot-error { background: var(--red); box-shadow: 0 0 6px var(--red); }

.widget-progress-inner { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.widget-ring { width: 100%; max-width: 120px; max-height: 120px; }
.widget-ring-text { position: absolute; text-align: center; }
.widget-ring-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); }
.widget-ring-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.widget-clock-inner { text-align: center; width: 100%; }
.widget-clock-time { font-size: 2.2rem; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); letter-spacing: 0.04em; }
.widget-clock-date { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

.widget-kpi-inner { width: 100%; display: flex; gap: 24px; justify-content: space-around; align-items: center; flex-wrap: wrap; }
.widget-kpi-item { text-align: center; }
.widget-kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.widget-kpi-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }
.widget-kpi-trend { font-size: 0.72rem; font-weight: 600; margin-top: 2px; }
.widget-kpi-trend.up { color: var(--green); }
.widget-kpi-trend.down { color: var(--red); }

.widget-note-inner { width: 100%; height: 100%; display: flex; flex-direction: column; }
.widget-note-content { flex: 1; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; overflow-y: auto; }

.widget-gauge-inner { text-align: center; width: 100%; }
.widget-gauge-svg { width: 100%; max-width: 140px; margin: 0 auto; display: block; }
.widget-gauge-value { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); margin-top: -4px; }
.widget-gauge-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

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

.widget-event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--bg-700);
  font-size: 0.8rem;
}
.widget-event-item:last-child { border-bottom: none; }
.widget-event-icon { font-size: 14px; flex-shrink: 0; }
.widget-event-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.02em;
  background: var(--citrus); color: #fff;
}
.widget-event-detail { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.widget-event-action { color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
.widget-event-entity { color: var(--citrus); font-size: 0.75rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.widget-event-time { color: var(--text-tertiary); font-size: 0.72rem; flex-shrink: 0; white-space: nowrap; }

.widget-add-btn {
  grid-column: span 3; grid-row: span 2;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--border); border-radius: 12px; color: var(--text-muted);
  font-size: 0.88rem; cursor: pointer; min-height: 100px; transition: all 0.2s;
}
.widget-add-btn:hover { border-color: var(--citrus); color: var(--citrus); background: rgba(124,58,237,0.03); }

/* Widget palette */
.widget-palette {
  position: fixed; right: 0; top: 0; bottom: 0; width: 320px;
  background: var(--bg-700); border-left: 1px solid var(--border); z-index: 100;
  overflow-y: auto; box-shadow: -4px 0 20px rgba(0,0,0,0.3); animation: slideInRight 0.2s ease;
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.palette-header-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text-primary);
}
.widget-type-list { padding: 12px; }
.widget-type-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px;
  border-radius: 10px; cursor: pointer; transition: background 0.15s;
}
.widget-type-item:hover { background: var(--bg-500); }
.wt-icon {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-500); border-radius: 8px; flex-shrink: 0; color: var(--citrus);
}
.wt-icon svg { width: 18px; height: 18px; }
.wt-name { font-weight: 600; font-size: 0.88rem; color: var(--text-primary); }
.wt-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }

/* ============================================================
   Admin Panel
   ============================================================ */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.admin-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-900);
  z-index: 1;
}
.admin-table tbody tr {
  transition: background 0.15s ease;
}
.admin-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}
.admin-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: middle;
  white-space: nowrap;
}
.admin-row-self {
  background: rgba(124,58,237,0.03);
}
.admin-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}
.admin-user-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: var(--citrus);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.admin-user-detail {
  min-width: 0;
}
.admin-user-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.admin-you-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--citrus);
  background: var(--citrus-glow);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
}
.admin-user-email {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.admin-org-cell {
  color: var(--text-secondary);
  font-size: 0.82rem;
}
.admin-date-cell {
  color: var(--text-muted);
  font-size: 0.82rem;
}
.admin-actions-cell {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.admin-empty-tab {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.admin-empty-tab svg {
  opacity: 0.3;
  margin-bottom: 12px;
}
.admin-empty-tab p {
  font-size: 0.88rem;
}
.tab-count {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--bg-500);
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 4px;
  color: var(--text-muted);
}
.tab-count-warn {
  background: var(--citrus-glow);
  color: var(--citrus);
}

.pending-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--citrus); animation: pulse-dot 2s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.3); } }

.role-options { display: flex; flex-direction: column; gap: 0.5rem; }
.role-option {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color 0.2s;
}
.role-option:hover { border-color: var(--accent); }
.role-option input[type="radio"] { accent-color: var(--accent); }
.role-option span { font-weight: 600; font-size: 0.9rem; }
.role-option small { font-size: 0.8rem; color: var(--text-secondary); margin-left: auto; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease-out);
    box-shadow: none;
  }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 16px 0 48px rgba(0,0,0,0.5); }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99;
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s;
  }
  .sidebar-overlay.visible { opacity: 1; visibility: visible; }
  .main-content { margin-left: 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .builder-palette { width: 200px; }
  .builder-properties { width: 260px; }
  .widget-grid { grid-template-columns: repeat(6, 1fr); }
  .widget-palette { width: 280px; }
  .breadcrumb { padding: 12px 20px 0; }
  .page-header { padding: 16px 20px 0; }
  .page-body { padding: 20px; }
  .mobile-menu-btn {
    position: fixed; top: 14px; left: 14px; z-index: 101;
    width: 40px; height: 40px; border-radius: var(--radius-md);
    background: var(--bg-700); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary); transition: all 0.2s ease;
  }
  .mobile-menu-btn:hover { background: var(--bg-600); color: var(--text-primary); }
  .mobile-menu-btn svg { width: 20px; height: 20px; }
}
@media (min-width: 1025px) {
  .mobile-menu-btn { display: none; }
  .sidebar-overlay { display: none; }
}
@media (max-width: 768px) {
  .stats-row { grid-template-columns: 1fr; }
  .grid-2, .form-row { grid-template-columns: 1fr; }
  .page-header { padding: 16px; flex-direction: column; }
  .page-body { padding: 16px; }
  .breadcrumb { padding: 12px 16px 0; }
  .builder-palette { display: none; }
  .widget-grid { grid-template-columns: repeat(3, 1fr); }
  .widget-palette { width: 100%; }
  .auth-card { padding: 32px 24px; }
  .admin-table-wrap { font-size: 0.82rem; }
  .admin-user-cell { min-width: 180px; }
  .admin-actions-cell .btn { padding: 5px 10px; font-size: 0.75rem; }
  .tabs { gap: 0; }
  .tab { padding: 10px 14px; font-size: 0.82rem; }
  /* Integrations responsive */
  .int-catalog-header { flex-direction: column; }
  .int-search-input-wrap { min-width: 100%; }
  .integrations-catalog-grid { grid-template-columns: 1fr; }
  .integrations-active-grid { grid-template-columns: 1fr; }
  .int-category-tabs { gap: 4px; }
  .int-cat-tab { padding: 4px 10px; font-size: 0.72rem; }
  .int-type-add-hint { display: none; }
}

/* ── App Footer ── */
.app-footer {
  margin-top: auto;
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.footer-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.footer-logo {
  flex-shrink: 0;
  opacity: 0.5;
}
.footer-copy {
  letter-spacing: 0.02em;
}
.footer-version-badge {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--citrus);
  background: var(--citrus-glow);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1;
}
.footer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.footer-dev {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}
.footer-dev:hover {
  color: var(--text-primary);
}
.footer-dev svg {
  opacity: 0.6;
  transition: opacity var(--transition);
}
.footer-dev:hover svg {
  opacity: 1;
}
.footer-amp {
  color: var(--text-tertiary);
  font-size: 0.7rem;
  user-select: none;
}
@media (max-width: 600px) {
  .app-footer { padding: 0.75rem 1rem; }
  .footer-inner { flex-direction: column; gap: 0.5rem; justify-content: center; }
  .footer-right { flex-wrap: wrap; justify-content: center; }
}

/* ============================================================
   AI Chat Panel — Citrus AI
   ============================================================ */

/* Toggle button */
.ai-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(124,58,237,0.4), 0 0 0 0 rgba(124,58,237,0.3);
  z-index: 9000;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: ai-pulse 3s ease-in-out infinite;
}
.ai-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(124,58,237,0.5);
}
.ai-toggle-btn.open {
  animation: none;
  box-shadow: 0 4px 20px rgba(124,58,237,0.3);
}
.ai-toggle-btn svg {
  width: 24px;
  height: 24px;
  color: #fff;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ai-toggle-btn .ai-icon-close { display: none; }
.ai-toggle-btn.open .ai-icon-chat { display: none; }
.ai-toggle-btn.open .ai-icon-close {
  display: block;
  animation: ai-spin-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(124,58,237,0.4), 0 0 0 0 rgba(124,58,237,0.3); }
  50% { box-shadow: 0 4px 24px rgba(124,58,237,0.4), 0 0 0 10px rgba(124,58,237,0); }
}
@keyframes ai-spin-in {
  from { transform: rotate(-90deg) scale(0.5); opacity: 0; }
  to { transform: rotate(0) scale(1); opacity: 1; }
}

/* Panel — FIXED dimensions, never resizes */
.ai-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 400px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9001;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: opacity, transform;
}
.ai-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header — fixed, never collapses */
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-800);
  flex: 0 0 auto;
}
.ai-panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-panel-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg-800);
}
.ai-panel-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.ai-panel-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.2;
}
.ai-panel-header-actions {
  display: flex;
  gap: 4px;
}
.ai-header-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.ai-header-btn:hover {
  background: var(--bg-600);
  color: var(--text-primary);
}

/* Messages area — scrollable, fills all available space */
.ai-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.ai-messages::-webkit-scrollbar { width: 5px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.ai-messages::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* Welcome screen */
.ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px 8px;
  gap: 6px;
}
.ai-welcome-icon {
  margin-bottom: 4px;
  opacity: 0.85;
}
.ai-welcome h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}
.ai-welcome p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 280px;
}
.ai-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-top: 10px;
}
.ai-suggestion {
  background: var(--bg-600);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: all 0.15s;
}
.ai-suggestion:hover {
  border-color: var(--citrus);
  color: var(--citrus);
  background: var(--citrus-glow);
}

/* Message bubbles */
.ai-msg {
  display: flex;
  gap: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.25s ease-out;
  flex-shrink: 0;
}
.ai-msg.visible {
  opacity: 1;
  transform: translateY(0);
}
.ai-msg-user {
  flex-direction: row-reverse;
}
.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: break-word;
}
.ai-msg-assistant .ai-msg-bubble {
  background: var(--bg-600);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.ai-msg-user .ai-msg-bubble {
  background: var(--citrus);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg-bubble code {
  background: rgba(0,0,0,0.25);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.ai-msg-bubble pre.ai-code-block {
  background: rgba(0,0,0,0.3);
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  overflow-x: auto;
  margin: 6px 0;
  white-space: pre-wrap;
}
.ai-msg-bubble strong { font-weight: 700; }
.ai-msg-bubble .ai-list-num {
  color: var(--citrus);
  font-weight: 700;
  margin-right: 2px;
}
.ai-msg-bubble .ai-list-bullet {
  color: var(--citrus);
  margin-right: 4px;
}

/* Typing dots */
.ai-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-600);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.ai-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: ai-dot-bounce 1.2s ease-in-out infinite;
}
.ai-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Input area — fixed at bottom, never collapses */
.ai-input-area {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-800);
  flex: 0 0 auto;
}
.ai-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ai-input-wrap input {
  flex: 1;
  min-width: 0;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}
.ai-input-wrap input:focus {
  border-color: var(--citrus);
  box-shadow: 0 0 0 3px var(--citrus-glow);
}
.ai-input-wrap input::placeholder {
  color: var(--text-muted);
}
.ai-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--citrus);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.ai-send-btn:hover:not(:disabled) {
  background: var(--citrus-dark);
  transform: translateY(-1px);
}
.ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ai-powered {
  text-align: center;
  font-size: 0.62rem;
  color: var(--text-tertiary);
  margin-top: 6px;
  letter-spacing: 0.03em;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
  .ai-panel {
    right: 8px;
    left: 8px;
    bottom: 84px;
    width: auto;
    height: calc(100vh - 100px);
    max-height: none;
    border-radius: var(--radius-lg);
  }
  .ai-toggle-btn {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
}

/* ============================================================
   Settings Page
   ============================================================ */
.settings-content { margin-top: 24px; }
.settings-section { display: flex; flex-direction: column; gap: 24px; }

.settings-card {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: border-color 0.25s;
}
.settings-card:hover { border-color: var(--border-hover); }

.settings-card-header { margin-bottom: 24px; }
.settings-card-header h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.settings-card-header p { font-size: 0.85rem; color: var(--text-secondary); }

.settings-form { display: flex; flex-direction: column; gap: 20px; }
.settings-form-actions { display: flex; justify-content: flex-end; padding-top: 8px; }
.settings-note { font-size: 0.82rem; color: var(--text-muted); font-style: italic; padding-top: 8px; }

.settings-avatar-section {
  display: flex; align-items: center; gap: 20px;
  padding: 20px; background: var(--bg-700); border-radius: var(--radius-md);
  margin-bottom: 24px; border: 1px solid var(--border);
}
.settings-avatar-wrapper { position: relative; flex-shrink: 0; }
.settings-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--citrus), var(--citrus-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: #fff;
  flex-shrink: 0; overflow: hidden;
}
.settings-avatar-img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
}
.settings-avatar-upload {
  position: absolute; bottom: -2px; right: -2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--citrus); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 2px solid var(--bg-700);
  transition: transform 0.2s, background 0.2s;
}
.settings-avatar-upload:hover { transform: scale(1.1); background: var(--citrus-dark); }
.settings-avatar-info { display: flex; flex-direction: column; gap: 2px; }
.settings-avatar-name { font-size: 1.1rem; font-weight: 700; }
.settings-avatar-role { font-size: 0.82rem; color: var(--citrus); font-weight: 600; }
.settings-avatar-email { font-size: 0.82rem; color: var(--text-muted); }

.settings-org-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px;
}

.settings-quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Theme Picker ── */
.settings-theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 480px;
}
.settings-theme-option {
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.settings-theme-option:hover {
  border-color: var(--text-muted);
}
.settings-theme-option.active {
  border-color: var(--citrus);
  box-shadow: 0 0 0 3px var(--citrus-glow);
}
.settings-theme-preview {
  display: flex;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
}
.settings-theme-preview .theme-preview-sidebar {
  width: 32%;
  flex-shrink: 0;
}
.settings-theme-preview .theme-preview-content {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-theme-preview .theme-preview-bar {
  height: 8px;
  border-radius: 3px;
  width: 60%;
}
.settings-theme-preview .theme-preview-cards {
  display: flex;
  gap: 4px;
  flex: 1;
}
.settings-theme-preview .theme-preview-card {
  flex: 1;
  border-radius: 4px;
}
.dark-preview .theme-preview-sidebar { background: #1a1a2e; }
.dark-preview .theme-preview-content { background: #0f0f1a; }
.dark-preview .theme-preview-bar { background: #2a2a3e; }
.dark-preview .theme-preview-card { background: #1e1e30; }
.light-preview .theme-preview-sidebar { background: #e5e5e5; }
.light-preview .theme-preview-content { background: #f5f5f7; }
.light-preview .theme-preview-bar { background: #d4d4d8; }
.light-preview .theme-preview-card { background: #e4e4e7; }
.settings-theme-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.settings-theme-option.active .settings-theme-label {
  color: var(--citrus);
}

/* ── Keyboard Shortcuts ── */
.settings-shortcuts-list {
  display: flex;
  flex-direction: column;
}
.settings-shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-shortcut-row:last-child { border-bottom: none; }
.settings-shortcut-label {
  font-size: 0.9rem;
  color: var(--text-primary);
}
.settings-shortcut-keys {
  display: flex;
  gap: 4px;
}
.settings-shortcut-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 3px 8px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Credits (bottom of Settings page) ── */
.settings-credits {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.settings-credits-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.settings-credits-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}
.settings-credits-devs {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-credit-dev {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.2s;
}
.settings-credit-dev:hover {
  color: var(--citrus);
}
.settings-credit-dev svg {
  opacity: 0.7;
  transition: opacity 0.2s;
}
.settings-credit-dev:hover svg {
  opacity: 1;
}
.settings-credits-amp {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── Advanced Settings Cards ── */
.settings-advanced-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-advanced-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.settings-advanced-card:hover {
  background: var(--bg-600);
  border-color: var(--citrus);
  transform: translateX(4px);
}
.settings-advanced-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-500);
  color: var(--citrus);
  flex-shrink: 0;
  transition: background 0.2s;
}
.settings-advanced-card:hover .settings-advanced-card-icon {
  background: var(--citrus);
  color: #fff;
}
.settings-advanced-card-info {
  flex: 1;
  min-width: 0;
}
.settings-advanced-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.settings-advanced-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.settings-advanced-card-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transform: rotate(-90deg);
  transition: color 0.2s, transform 0.2s;
}
.settings-advanced-card:hover .settings-advanced-card-arrow {
  color: var(--citrus);
  transform: rotate(-90deg) translateY(2px);
}

/* ============================================================
   Analytics Dashboard
   ============================================================ */

.analytics-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

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

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

.analytics-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.analytics-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.analytics-period-select {
  background: var(--bg-200);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.analytics-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 64px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.analytics-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Stat Cards ── */
.analytics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.analytics-stat-card {
  background: var(--bg-200);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.analytics-stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
}

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

.analytics-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.analytics-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-top: 2px;
}

.analytics-stat-lg {
  font-size: 1.6rem;
}

/* ── Panels ── */
.analytics-panel {
  background: var(--bg-200);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.analytics-panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-sub-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 16px;
  margin-bottom: 8px;
}

.analytics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.analytics-panel-half {
  margin-bottom: 0;
}

.analytics-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px 0;
}

/* ── Charts ── */
.analytics-chart-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

.analytics-chart {
  width: 100%;
  height: auto;
  display: block;
}

.analytics-chart-label {
  font-size: 9px;
  fill: var(--text-muted);
  font-family: inherit;
}

.analytics-chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.analytics-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.analytics-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.analytics-bar-group rect {
  transition: opacity 0.15s;
  cursor: pointer;
}

.analytics-bar-group:hover rect {
  opacity: 1 !important;
}

.analytics-growth-chart {
  max-height: 200px;
}

/* ── Donut ── */
.analytics-donut-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.analytics-donut {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.analytics-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Mini Table ── */
.analytics-mini-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.analytics-mini-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-100);
  font-size: 0.82rem;
}

.analytics-mini-name {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-mini-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.analytics-mini-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ── Full Table ── */
.analytics-table-wrap {
  overflow-x: auto;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.analytics-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.analytics-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-light, var(--border));
  color: var(--text-primary);
}

.analytics-table tbody tr:hover {
  background: var(--bg-100);
}

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

/* ── Leaderboard ── */
.analytics-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.analytics-leader-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.analytics-leader-row:hover {
  background: var(--bg-100);
}

.analytics-leader-rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.analytics-leader-row:first-child .analytics-leader-rank {
  background: var(--accent);
  color: #fff;
}

.analytics-leader-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-400, var(--bg-300));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

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

.analytics-leader-info {
  flex: 1;
  min-width: 0;
}

.analytics-leader-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-leader-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.analytics-leader-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

/* ── Schedule Bar ── */
.analytics-schedule-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
}

.analytics-schedule-stat {
  text-align: center;
  flex: 1;
}

.analytics-schedule-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--bg-300);
  margin-bottom: 8px;
}

.analytics-schedule-bar-fill {
  height: 100%;
  transition: width 0.5s var(--ease-out);
}

.analytics-schedule-bar-success {
  background: #22c55e;
}

.analytics-schedule-bar-error {
  background: #ef4444;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .analytics-header {
    flex-direction: column;
  }
  .analytics-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .analytics-row {
    grid-template-columns: 1fr;
  }
  .analytics-donut-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .analytics-cards {
    grid-template-columns: 1fr;
  }
  .analytics-page {
    padding: 20px 12px 32px;
  }
}

/* ── Light Theme Overrides ── */
[data-theme="light"] .analytics-stat-card {
  background: #fff;
}
[data-theme="light"] .analytics-panel {
  background: #fff;
}
[data-theme="light"] .analytics-mini-row {
  background: #f8fafc;
}
[data-theme="light"] .analytics-leader-row:hover {
  background: #f1f5f9;
}

/* ── Toggle Switches ── */
.settings-toggles { display: flex; flex-direction: column; }

.settings-toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.settings-toggle-row:last-child { border-bottom: none; }
.settings-toggle-info { display: flex; flex-direction: column; gap: 2px; }
.settings-toggle-label { font-size: 0.92rem; font-weight: 600; }
.settings-toggle-desc { font-size: 0.8rem; color: var(--text-muted); }

.toggle-switch {
  position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-500); border-radius: 24px;
  transition: background 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}
.toggle-slider::before {
  content: ''; position: absolute; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%;
  transition: transform 0.3s var(--ease-spring);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--citrus); box-shadow: 0 0 16px var(--citrus-glow); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:focus + .toggle-slider { box-shadow: 0 0 0 3px var(--citrus-glow); }
.toggle-switch:hover .toggle-slider { box-shadow: 0 0 0 2px rgba(255,255,255,0.06); }
.toggle-switch:active .toggle-slider::before { width: 22px; }

/* ============================================================
   Notifications Panel
   ============================================================ */
.notif-bell {
  position: relative; background: none; border: none; cursor: pointer;
  color: var(--text-secondary); padding: 6px; border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
  margin-left: auto; display: flex; align-items: center; justify-content: center;
}
.notif-bell svg { width: 18px; height: 18px; }
.notif-bell:hover { color: var(--text-primary); background: var(--bg-600); }
.notif-badge {
  position: absolute; top: 0; right: 0;
  background: var(--red); color: #fff; font-size: 0.65rem; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
  animation: badge-pop 0.3s var(--ease-spring);
}
@keyframes badge-pop { from { transform: scale(0); } to { transform: scale(1); } }

.notif-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 999;
  opacity: 0; transition: opacity 0.2s;
}
.notif-overlay.visible { opacity: 1; }

.notif-panel {
  position: fixed; top: 0; right: -420px; width: 400px; height: 100vh;
  background: var(--bg-800); border-left: 1px solid var(--border);
  z-index: 1000; display: flex; flex-direction: column;
  transition: right 0.3s var(--ease-out);
  box-shadow: var(--shadow-xl);
}
.notif-panel.open { right: 0; }

.notif-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.notif-panel-header h3 { font-size: 1rem; font-weight: 700; }
.notif-panel-actions { display: flex; align-items: center; gap: 8px; }

.notif-panel-body { flex: 1; overflow-y: auto; }

.notif-item {
  display: flex; gap: 12px; padding: 14px 24px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
}
.notif-item:hover { background: var(--bg-700); }
.notif-item.unread { background: rgba(124,58,237,0.04); }
.notif-item-icon { flex-shrink: 0; padding-top: 2px; color: var(--text-muted); }
.notif-item.unread .notif-item-icon { color: var(--citrus); }
.notif-item-content { flex: 1; min-width: 0; }
.notif-item-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
.notif-item.unread .notif-item-title { color: var(--text-primary); }
.notif-item:not(.unread) .notif-item-title { color: var(--text-secondary); }
.notif-item-body { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-time { font-size: 0.72rem; color: var(--text-tertiary); }
.notif-item-dot {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  background: var(--citrus); margin-top: 6px;
}

.notif-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 24px; color: var(--text-muted);
  text-align: center;
}
.notif-empty p { font-weight: 600; margin-top: 16px; font-size: 0.95rem; }
.notif-empty span { font-size: 0.82rem; margin-top: 4px; }

/* ── Notification Filter Tabs ── */
.notif-filter-tabs {
  display: flex; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0;
}
.notif-filter-tabs::-webkit-scrollbar { height: 0; }
.notif-filter-tab {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 6px; border: none;
  background: transparent; color: var(--text-muted);
  font-size: 0.75rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: all 0.15s;
}
.notif-filter-tab:hover { background: var(--bg-700); color: var(--text-secondary); }
.notif-filter-tab.active { background: var(--citrus-10); color: var(--citrus); font-weight: 600; }
.notif-filter-count {
  font-size: 0.65rem; font-weight: 700; background: var(--citrus-10);
  color: var(--citrus); padding: 0 5px; border-radius: 10px; min-width: 14px;
  text-align: center; line-height: 16px;
}
.notif-filter-tab.active .notif-filter-count { background: var(--citrus); color: var(--bg-900); }

/* ── Notification Date Groups ── */
.notif-date-group { display: flex; flex-direction: column; }
.notif-date-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-tertiary);
  padding: 10px 24px 4px; background: var(--bg-800);
  position: sticky; top: 0; z-index: 1;
}

/* ── Notification Item Actions ── */
.notif-item-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s;
}
.notif-item:hover .notif-item-actions { opacity: 1; }
.notif-action-btn { padding: 4px !important; border-radius: 4px !important; }
.notif-action-btn:hover { background: var(--bg-600) !important; }

/* ── Notification More Menu ── */
.notif-more-menu { position: relative; }
.notif-dropdown {
  position: absolute; top: 100%; right: 0; min-width: 200px;
  background: var(--bg-700); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-xl);
  z-index: 10; padding: 4px;
}
.notif-dropdown button {
  display: block; width: 100%; padding: 8px 12px; text-align: left;
  background: none; border: none; color: var(--text-secondary);
  font-size: 0.8rem; border-radius: 6px; cursor: pointer;
}
.notif-dropdown button:hover { background: var(--bg-600); color: var(--text-primary); }

/* ── Notification Panel Header icon ── */
.notif-panel-header h3 { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   Activity Feed
   ============================================================ */
.activity-feed { display: flex; flex-direction: column; }

.activity-item {
  display: flex; gap: 16px; padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  position: relative;
}
.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--citrus); flex-shrink: 0; margin-top: 6px;
  box-shadow: 0 0 8px var(--citrus-glow);
}
.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.activity-text strong { color: var(--text-primary); font-weight: 600; }
.activity-time { font-size: 0.75rem; color: var(--text-tertiary); margin-top: 4px; }

.activity-empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px; color: var(--text-muted); text-align: center;
}

/* ── Settings responsive ── */
@media (max-width: 768px) {
  .settings-avatar-section { flex-direction: column; text-align: center; }
  .settings-org-stats { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .notif-panel { width: 100%; right: -100%; }
}

/* ============================================================
   Onboarding Wizard
   ============================================================ */
.onboarding-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s; backdrop-filter: blur(4px);
}
.onboarding-overlay.visible { opacity: 1; }
.onboarding-modal {
  background: var(--bg-800); border: 1px solid var(--border);
  border-radius: 16px; width: 520px; max-width: 92vw;
  box-shadow: var(--shadow-xl); overflow: hidden;
  animation: onboard-in 0.4s var(--ease-spring);
}
@keyframes onboard-in {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.onboarding-progress {
  display: flex; justify-content: center; gap: 8px; padding: 20px 24px 0;
}
.onboarding-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg-600); transition: all 0.3s;
}
.onboarding-dot.active {
  background: var(--citrus); width: 24px; border-radius: 4px;
  box-shadow: 0 0 8px var(--citrus-glow);
}
.onboarding-dot.done { background: var(--citrus); opacity: 0.5; }
.onboarding-body {
  padding: 32px 32px 24px; text-align: center;
}
.onboarding-icon {
  color: var(--citrus); margin-bottom: 16px;
  animation: onboard-icon 0.5s var(--ease-spring) 0.2s both;
}
@keyframes onboard-icon {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}
.onboarding-title {
  font-size: 1.3rem; font-weight: 800; margin-bottom: 8px;
  color: var(--text-primary);
}
.onboarding-desc {
  font-size: 0.88rem; color: var(--text-muted); line-height: 1.6;
  max-width: 380px; margin: 0 auto;
}

/* ── Onboarding Features Grid ── */
.onboarding-features {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 24px; text-align: left;
}
.onboarding-feature {
  display: flex; gap: 10px; padding: 12px; border-radius: 10px;
  background: var(--bg-700); border: 1px solid var(--border);
}
.onboarding-feature-icon {
  color: var(--citrus); flex-shrink: 0; padding-top: 2px;
}
.onboarding-feature strong {
  display: block; font-size: 0.82rem; font-weight: 700; color: var(--text-primary);
  margin-bottom: 2px;
}
.onboarding-feature span {
  font-size: 0.75rem; color: var(--text-muted);
}

/* ── Onboarding Action Cards ── */
.onboarding-action-card {
  margin-top: 20px; padding: 16px; border-radius: 10px;
  background: var(--bg-700); border: 1px solid var(--border);
  text-align: left;
}
.onboarding-action-card p {
  font-size: 0.82rem; color: var(--text-muted); margin-bottom: 12px;
}
.onboarding-mini-form {
  display: flex; flex-direction: column; gap: 10px;
}
.onboarding-mini-form .btn { align-self: flex-start; }

/* ── Onboarding Checklist Preview ── */
.onboarding-checklist-preview {
  margin-top: 20px; text-align: left;
  display: flex; flex-direction: column; gap: 6px;
}
.onboarding-check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 0.82rem; color: var(--text-secondary);
  background: var(--bg-700); border: 1px solid var(--border);
}
.onboarding-check-item.done {
  color: var(--citrus); text-decoration: line-through;
  opacity: 0.7;
}
.onboarding-finish-note {
  font-size: 0.75rem; color: var(--text-tertiary); margin-top: 12px;
}

/* ── Onboarding Footer ── */
.onboarding-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-top: 1px solid var(--border);
}
.onboarding-nav { display: flex; gap: 8px; }

/* ── Dashboard Checklist Widget ── */
.onboarding-checklist-widget {
  background: var(--bg-800); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px; margin-bottom: 20px;
  transition: opacity 0.2s;
}
.ocw-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.ocw-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 0.88rem; color: var(--text-primary);
}
.ocw-title svg { color: var(--citrus); }
.ocw-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ocw-progress-bar {
  flex: 1; height: 4px; border-radius: 4px;
  background: var(--bg-600); overflow: hidden;
}
.ocw-progress-fill {
  height: 100%; background: var(--citrus); border-radius: 4px;
  transition: width 0.4s var(--ease-out);
}
.ocw-progress-text {
  font-size: 0.72rem; color: var(--text-muted); white-space: nowrap;
}
.ocw-items { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.ocw-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 6px; font-size: 0.82rem;
  color: var(--text-secondary); transition: background 0.15s;
}
.ocw-item:hover { background: var(--bg-700); }
.ocw-item.done { color: var(--citrus); text-decoration: line-through; opacity: 0.7; }
.ocw-check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.ocw-item.done .ocw-check {
  border-color: var(--citrus); background: var(--citrus-10); color: var(--citrus);
}
.ocw-restart {
  width: 100%; justify-content: center;
}

@media (max-width: 520px) {
  .onboarding-features { grid-template-columns: 1fr; }
  .onboarding-modal { border-radius: 12px; }
  .onboarding-body { padding: 24px 20px 16px; }
}

/* ============================================================
   Audit Log Viewer
   ============================================================ */
.audit-toolbar { display: flex; gap: 8px; }
.audit-filters {
  background: var(--bg-800); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
}
.audit-filter-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.audit-filter-field { margin: 0; flex: 1; min-width: 140px; }
.audit-filter-field .form-input-sm {
  font-size: 0.8rem; padding: 6px 10px; height: 34px;
}
.audit-summary {
  font-size: 0.78rem; color: var(--text-muted); margin-bottom: 8px;
}
.audit-table-wrap { overflow-x: auto; }
.audit-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.82rem;
}
.audit-table thead th {
  text-align: left; padding: 10px 12px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.audit-row {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
}
.audit-row:hover { background: var(--bg-700); }
.audit-row td { padding: 10px 12px; vertical-align: middle; }
.audit-time { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.audit-user { font-weight: 600; color: var(--text-secondary); }
.audit-action-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 6px;
  font-size: 0.75rem; font-weight: 600;
  background: color-mix(in srgb, var(--action-color) 12%, transparent);
  color: var(--action-color);
}
.audit-entity-type {
  font-size: 0.78rem; color: var(--text-muted);
  text-transform: capitalize;
}
.audit-entity-name {
  font-size: 0.82rem; color: var(--text-secondary);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.audit-empty {
  text-align: center; padding: 40px 24px;
  color: var(--text-muted); font-size: 0.85rem;
}
.audit-pagination { margin-top: 16px; }
.audit-pag-btns {
  display: flex; justify-content: center; gap: 4px;
}

/* ── Audit Detail Drawer ── */
.audit-detail-drawer .notif-panel-body { padding: 0; }
.audit-detail-section {
  padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.audit-detail-section:last-child { border-bottom: none; }
.audit-detail-section label {
  display: block; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-tertiary); margin-bottom: 4px;
}
.audit-detail-section > div { font-size: 0.85rem; color: var(--text-primary); }
.audit-detail-id {
  font-family: 'SF Mono', monospace; font-size: 0.75rem;
  color: var(--text-muted); word-break: break-all;
}
.audit-detail-json {
  font-family: 'SF Mono', monospace; font-size: 0.75rem;
  background: var(--bg-900); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px; margin-top: 4px;
  overflow-x: auto; color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-word;
}

@media (max-width: 768px) {
  .audit-filter-row { flex-direction: column; }
  .audit-filter-field { min-width: 100%; }
}

/* ============================================================
   Workspace Dashboard Cards — Enhanced
   ============================================================ */
.ws-card-enhanced {
  display: flex; flex-direction: column; gap: 0; padding: 0;
  overflow: hidden; transition: transform 0.2s, box-shadow 0.2s;
}
.ws-card-enhanced:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-xl);
}
.ws-card-top {
  padding: 18px 20px 14px; position: relative;
}
.ws-health-dot {
  width: 8px; height: 8px; border-radius: 50%;
  position: absolute; top: 18px; right: 20px;
  box-shadow: 0 0 6px currentColor;
}
.ws-card-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--bg-900);
}
.ws-mini-stat {
  padding: 10px 12px; text-align: center;
  border-right: 1px solid var(--border);
}
.ws-mini-stat:last-child { border-right: none; }
.ws-mini-val {
  font-size: 1.1rem; font-weight: 800; color: var(--text-primary);
  line-height: 1.2;
}
.ws-mini-sub {
  font-size: 0.7rem; font-weight: 500; color: var(--text-tertiary);
}
.ws-mini-label {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-tertiary); margin-top: 2px;
}
.ws-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; font-size: 0.75rem;
}
.ws-health-label {
  display: flex; align-items: center; gap: 4px;
  font-weight: 600; font-size: 0.72rem;
}
.ws-activity-time {
  color: var(--text-tertiary); font-size: 0.72rem;
}

@media (max-width: 480px) {
  .ws-card-stats { grid-template-columns: repeat(2, 1fr); }
  .ws-mini-stat:nth-child(2) { border-right: none; }
}

/* ============================================================
   Micro-Interactions — Calm & Peaceful Polish
   Dopamine, serotonin, every interaction on purpose
   ============================================================ */

/* ── Ambient stat card breathe on hover ── */
@keyframes stat-glow {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.15); }
  50% { box-shadow: 0 8px 28px rgba(0,0,0,0.22), 0 0 0 1px rgba(124,58,237,0.06); }
}
.stat-card:hover {
  animation: stat-glow 2.5s ease-in-out infinite;
}

/* ── Card hover glow ring ── */
.card {
  transition: all 0.3s var(--ease-out), box-shadow 0.4s ease;
}
.workspace-card:hover,
.flow-card:hover,
.deployment-card:hover,
.int-type-card:hover {
  box-shadow: 0 12px 32px rgba(0,0,0,0.25), 0 0 0 1px rgba(124,58,237,0.08), inset 0 1px 0 rgba(255,255,255,0.03);
}

/* ── Smooth breadcrumb hover ── */
.breadcrumb a {
  transition: color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
  display: inline-block;
}
.breadcrumb a:hover { transform: translateY(-1px); }
.breadcrumb-sep {
  transition: color 0.3s;
  display: inline-block;
}

/* ── Badge entrance animation ── */
.badge {
  animation: badge-enter 0.3s var(--ease-spring) both;
}
@keyframes badge-enter {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Button hover lift ── */
.btn {
  transition: all 0.2s var(--ease-out), box-shadow 0.25s ease, transform 0.2s var(--ease-spring);
}

/* ── Empty state float animation ── */
.empty-state svg {
  animation: empty-float 4s ease-in-out infinite;
}
@keyframes empty-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ── Section header label subtle entrance ── */
.section-header {
  animation: section-slide 0.4s var(--ease-out) both;
}
@keyframes section-slide {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Card star pop on click ── */
.card-star:active,
.ws-nav-star:active {
  animation: star-pop 0.3s var(--ease-spring);
}
@keyframes star-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ── Toast entrance improved ── */
.toast {
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
}

/* ── Search results fade-in ── */
.sidebar-search-results {
  animation: search-results-in 0.2s var(--ease-out);
}
@keyframes search-results-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-result-item {
  transition: background 0.2s, transform 0.15s var(--ease-out);
}
.search-result-item:hover {
  transform: translateX(3px);
}

/* ── Sidebar nav item smooth press ── */
.nav-item {
  transition: all 0.2s var(--ease-out), transform 0.15s var(--ease-spring);
}
.nav-item:active {
  transform: scale(0.96) translateX(1px);
}
.nav-item.active {
  transition: all 0.3s var(--ease-out);
}
.nav-item.active::before {
  animation: active-bar-in 0.3s var(--ease-spring) both;
}
@keyframes active-bar-in {
  from { height: 0; opacity: 0; }
  to { height: 18px; opacity: 1; }
}

/* ── Workspace tree item transitions ── */
.ws-nav-item {
  transition: background 0.25s var(--ease-out), transform 0.2s;
}
.ws-nav-item.ws-active {
  animation: ws-active-in 0.3s var(--ease-out);
}
@keyframes ws-active-in {
  from { background: transparent; }
  to { background: rgba(124, 58, 237, 0.04); }
}

/* ── Sidebar favorites remove button ── */
.nav-fav-remove {
  transition: opacity 0.2s, color 0.2s, transform 0.2s var(--ease-spring);
}
.nav-fav-remove:hover { transform: scale(1.15); }

/* ── Settings card hover lift ── */
.settings-card {
  transition: border-color 0.3s, transform 0.3s var(--ease-out), box-shadow 0.3s;
}
.settings-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ── Activity feed dot pulse ── */
.activity-dot {
  animation: activity-pulse 2s ease-in-out infinite;
}
@keyframes activity-pulse {
  0%, 100% { box-shadow: 0 0 6px var(--citrus-glow); opacity: 1; }
  50% { box-shadow: 0 0 14px var(--citrus-glow-strong); opacity: 0.7; }
}

/* ── Notification item slide ── */
.notif-item {
  transition: background 0.2s, transform 0.2s var(--ease-out);
}
.notif-item:hover { transform: translateX(3px); }
.notif-item:active { transform: scale(0.99); }

/* ── Integration category tab spring ── */
.int-cat-tab {
  transition: all 0.25s var(--ease-spring);
}
.int-cat-tab:active { transform: scale(0.95); }
.int-cat-tab.active {
  animation: cat-tab-active 0.3s var(--ease-spring);
}
@keyframes cat-tab-active {
  from { transform: scale(0.9); }
  to { transform: scale(1); }
}

/* ── Modal backdrop improved blur ── */
.modal-overlay {
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
}

/* ── Smooth scrollbar appearance ── */
.sidebar-nav::-webkit-scrollbar-thumb {
  transition: background 0.3s;
}

/* ── Page header title entrance ── */
.page-header h1,
.page-header .page-title {
  animation: title-in 0.4s var(--ease-out) both;
}
@keyframes title-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-header p,
.page-header .page-subtitle {
  animation: subtitle-in 0.5s var(--ease-out) 0.1s both;
}
@keyframes subtitle-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Smooth global transitions ── */
a {
  transition: color 0.2s var(--ease-out);
}

/* ── Stagger animation improved easing ── */
.stagger-item {
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  animation: stagger-in 0.45s var(--ease-out) forwards;
}
@keyframes stagger-in {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Andon card status bar shimmer ── */
.andon-card.status-ok::before {
  background: linear-gradient(90deg, var(--green), #4ade80, var(--green));
  background-size: 200% 100%;
  animation: status-shimmer 3s ease-in-out infinite;
}
.andon-card.status-late::before,
.andon-card.status-late_backlog::before {
  animation: status-shimmer 2s ease-in-out infinite;
}
@keyframes status-shimmer {
  0%, 100% { background-position: 0% 0; }
  50% { background-position: 100% 0; }
}

/* ── Widget dot status glow ── */
.widget-dot.dot-ok { animation: dot-breathe-green 3s ease-in-out infinite; }
.widget-dot.dot-warning { animation: dot-breathe-yellow 2.5s ease-in-out infinite; }
.widget-dot.dot-error { animation: dot-breathe-red 1.8s ease-in-out infinite; }
@keyframes dot-breathe-green {
  0%, 100% { box-shadow: 0 0 4px var(--green); }
  50% { box-shadow: 0 0 12px var(--green); }
}
@keyframes dot-breathe-yellow {
  0%, 100% { box-shadow: 0 0 4px var(--yellow); }
  50% { box-shadow: 0 0 12px var(--yellow); }
}
@keyframes dot-breathe-red {
  0%, 100% { box-shadow: 0 0 4px var(--red); }
  50% { box-shadow: 0 0 12px var(--red); }
}

/* ── Smooth card-star reveal ── */
.card-star {
  transition: opacity 0.25s var(--ease-out), color 0.2s, transform 0.25s var(--ease-spring);
}

/* ── Footer version badge pop ── */
.footer-version-badge {
  animation: badge-enter 0.4s var(--ease-spring) 0.5s both;
}

/* ── Sidebar copyright subtle breathe ── */
.sidebar-copyright {
  animation: breathe 4s ease-in-out infinite;
}

/* ── Progress bar smooth fill ── */
.route-progress-bar {
  transition: width 0.8s var(--ease-out);
}

/* ── Global selection color ── */
::selection {
  background: rgba(124, 58, 237, 0.25);
  color: var(--text-primary);
}
::-moz-selection {
  background: rgba(124, 58, 237, 0.25);
  color: var(--text-primary);
}

/* ════════════════════════════════════════════════
   Admin Section Tabs (Users / Teams / Import)
   ════════════════════════════════════════════════ */
.admin-sections {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.admin-section-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}
.admin-section-tab:hover {
  color: var(--text-primary);
}
.admin-section-tab.active {
  color: var(--citrus);
  border-bottom-color: var(--citrus);
}

/* ── Admin sub-header (title + action button row) ── */
.admin-sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-sub-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Admin row error (import preview) ── */
.admin-row-error {
  background: rgba(239, 68, 68, 0.04);
}
.admin-row-error:hover {
  background: rgba(239, 68, 68, 0.07);
}

/* ════════════════════════════════════════════════
   Teams Grid
   ════════════════════════════════════════════════ */
.admin-teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.admin-team-card {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), border-color 0.2s, box-shadow 0.2s;
}
.admin-team-card:hover {
  transform: translateY(-2px);
  border-color: var(--citrus);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.08);
}
.admin-team-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.admin-team-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.admin-team-info {
  min-width: 0;
  flex: 1;
}
.admin-team-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.admin-team-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-team-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.admin-team-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Team Color Picker ── */
.team-color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.team-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.team-color-swatch:hover {
  transform: scale(1.15);
}
.team-color-swatch.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
  transform: scale(1.1);
}

/* ════════════════════════════════════════════════
   Import Upload Area
   ════════════════════════════════════════════════ */
.import-upload-area {
  background: var(--bg-700);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s, background 0.2s;
}
.import-upload-area:hover {
  border-color: var(--citrus);
  background: rgba(124, 58, 237, 0.02);
}
.import-upload-inner {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}
.import-upload-inner h3 {
  font-size: 1rem;
  color: var(--text-primary);
  margin: 12px 0 6px;
}
.import-upload-inner p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}
.import-upload-inner code {
  font-size: 0.78rem;
  color: var(--citrus);
  background: var(--bg-500);
  padding: 1px 6px;
  border-radius: 4px;
}
.import-upload-inner svg {
  opacity: 0.3;
}

/* ════════════════════════════════════════════════
   Responsive — Admin sections
   ════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .admin-teams-grid {
    grid-template-columns: 1fr;
  }
  .admin-sub-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ════════════════════════════════════════════════
   Code View — Python DSL Editor
   ════════════════════════════════════════════════ */

/* Mode toggle buttons in builder/code topbar */
.code-mode-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-700);
  border-radius: var(--radius-md);
  padding: 2px;
  margin-left: 12px;
}
.code-mode-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: var(--font);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}
.code-mode-btn:hover {
  color: var(--text-primary);
  background: var(--bg-500);
}
.code-mode-btn.active {
  background: var(--bg-400);
  color: var(--citrus);
  font-weight: 600;
}
.code-mode-btn svg {
  width: 14px;
  height: 14px;
}

/* Code view layout */
.code-view-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* Editor container */
.code-editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border);
}
.code-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-700);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.code-filename {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.code-filename svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}
.code-lang-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-500);
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.03em;
}

/* CodeMirror overrides for Citrus dark theme */
#code-editor-mount {
  flex: 1;
  overflow: hidden;
}
#code-editor-mount .CodeMirror {
  height: 100%;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  background: var(--bg-800, #0d1117);
}
#code-editor-mount .CodeMirror-gutters {
  background: var(--bg-800, #0d1117);
  border-right: 1px solid var(--border);
}
#code-editor-mount .CodeMirror-linenumber {
  color: var(--text-muted);
  padding: 0 8px;
}
#code-editor-mount .CodeMirror-cursor {
  border-left-color: var(--citrus);
}
#code-editor-mount .CodeMirror-selected {
  background: rgba(124, 58, 237, 0.12) !important;
}
#code-editor-mount .CodeMirror-activeline-background {
  background: rgba(255, 255, 255, 0.03);
}
#code-editor-mount .CodeMirror-matchingbracket {
  color: var(--citrus) !important;
  border-bottom: 1px solid var(--citrus);
}

/* Suggestions panel */
.code-suggestions-panel {
  width: 280px;
  background: var(--bg-600);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease, opacity 0.3s ease;
  flex-shrink: 0;
}
.code-suggestions-panel.collapsed {
  width: 0;
  opacity: 0;
  overflow: hidden;
}
.suggestions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.suggestions-header span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.suggestions-header svg {
  width: 16px;
  height: 16px;
  color: var(--citrus);
}
.suggestions-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.suggestions-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.suggestions-category {
  margin-bottom: 16px;
}
.suggestions-category-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 8px;
}
.suggestion-block {
  padding: 10px 12px;
  background: var(--bg-500);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.suggestion-block:hover {
  background: var(--bg-400);
  border-color: var(--citrus);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.1);
}
.suggestion-block:active {
  transform: scale(0.98);
}
.suggestion-block-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.suggestion-block-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Responsive — Code view */
@media (max-width: 1024px) {
  .code-suggestions-panel {
    width: 220px;
  }
}
@media (max-width: 768px) {
  .code-suggestions-panel {
    display: none;
  }
  .code-mode-toggle {
    margin-left: 8px;
  }
}

/* ════════════════════════════════════════════════
   APP ENGINE — Apps Manager Styles
   ════════════════════════════════════════════════ */

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.app-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.app-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.app-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.app-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-card-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.app-card-slug {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.app-status {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 9999px;
  margin-left: auto;
  flex-shrink: 0;
}
.app-status.draft {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
}
.app-status.published {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.app-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.4;
}

.app-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── App Detail ── */
.app-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 32px 16px;
  flex-wrap: wrap;
}

.app-detail-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-detail-info {
  flex: 1;
  min-width: 200px;
}

.app-detail-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.app-detail-slug {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.app-detail-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

.app-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── App Tabs ── */
.app-tabs {
  display: flex;
  gap: 0;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
}

.app-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.app-tab:hover {
  color: var(--text);
}
.app-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.app-tab-count {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 8px;
}
.app-tab.active .app-tab-count {
  background: rgba(124, 58, 237, 0.15);
}

.app-tab-content {
  padding: 24px 32px;
}

/* ── App Sections ── */
.app-section {
  margin-bottom: 32px;
}

.app-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.app-section-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.app-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 40px 20px;
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  border: 1px dashed var(--border);
}

/* ── Pages List ── */
.app-pages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-page-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s;
}
.app-page-item:hover {
  border-color: var(--accent);
}

.app-page-drag {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.app-page-info {
  flex: 1;
}
.app-page-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-page-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.app-page-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.app-page-item:hover .app-page-actions {
  opacity: 1;
}

/* ── Bindings ── */
.app-binding-group {
  margin-bottom: 16px;
}
.app-binding-type {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.app-binding-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 4px;
}
.app-binding-icon {
  color: var(--accent);
}
.app-binding-name {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text);
}

/* ── Access ── */
.app-access-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.app-access-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.app-access-grantee {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text);
}
.app-access-icon {
  color: var(--text-muted);
}

/* ── Protection & Passcodes ── */
.app-protection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.app-protection-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.app-protection-options {
  display: flex;
  gap: 6px;
}
.app-passcode-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-600);
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.1em;
  color: var(--citrus);
  font-weight: 600;
}

/* ── Versions ── */
.app-versions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.app-version-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.app-version-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  flex-shrink: 0;
}
.app-version-info {
  flex: 1;
}
.app-version-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}
.app-version-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Badges ── */
.badge-accent {
  background: rgba(124, 58, 237, 0.15);
  color: #7c3aed;
}
.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}
.badge-default {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
}

/* ── Form color input ── */
.form-color {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

/* ── Danger ghost text for inline delete buttons ── */
.btn-danger-text { color: var(--text-muted); }
.btn-danger-text:hover { color: #ef4444; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
  .app-detail-header {
    padding: 16px;
  }
  .app-tabs {
    padding: 0 16px;
    overflow-x: auto;
  }
  .app-tab-content {
    padding: 16px;
  }
  .app-detail-actions {
    width: 100%;
  }
  .app-page-actions {
    opacity: 1;
  }
}

/* ══════════════════════════════════════════════
   App Renderer — Client-Side Runtime
   ══════════════════════════════════════════════ */

.ar-shell {
  --ar-accent: #7c3aed;
  --ar-bg: #0a0a0f;
  --ar-surface: #12121a;
  --ar-surface-2: #1a1a24;
  --ar-border: #2a2a35;
  --ar-text: #e2e2e8;
  --ar-text-muted: #8b8b9a;
  --ar-topbar-h: 56px;
  --ar-sidebar-w: 240px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--ar-bg);
  color: var(--ar-text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Top Bar ── */
.ar-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--ar-topbar-h);
  padding: 0 20px;
  background: var(--ar-surface);
  border-bottom: 1px solid var(--ar-border);
  flex-shrink: 0;
  z-index: 100;
}
.ar-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ar-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ar-menu-toggle {
  background: none;
  border: none;
  color: var(--ar-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.ar-menu-toggle:hover {
  background: var(--ar-surface-2);
  color: var(--ar-text);
}
.ar-app-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ar-app-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ar-app-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--ar-text);
  line-height: 1.2;
}
.ar-app-org {
  font-size: 12px;
  color: var(--ar-text-muted);
}
.ar-preview-badge {
  background: #f59e0b20;
  color: #f59e0b;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.ar-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: ar-pulse 2s ease-in-out infinite;
}
@keyframes ar-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 #22c55e60; }
  50% { opacity: .7; box-shadow: 0 0 0 6px #22c55e00; }
}
.ar-live-text {
  font-size: 12px;
  font-weight: 600;
  color: #22c55e;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.ar-exit-btn {
  display: flex;
  align-items: center;
  color: var(--ar-text-muted);
  padding: 6px;
  border-radius: 6px;
  text-decoration: none;
  transition: all .15s;
}
.ar-exit-btn:hover {
  background: var(--ar-surface-2);
  color: var(--ar-text);
}

/* ── Body + Sidebar ── */
.ar-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.ar-sidebar {
  width: var(--ar-sidebar-w);
  flex-shrink: 0;
  background: var(--ar-surface);
  border-right: 1px solid var(--ar-border);
  overflow-y: auto;
  padding: 16px 0;
  transition: width .25s ease, opacity .25s ease;
}
.ar-sidebar.collapsed {
  width: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}
.ar-sidebar-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ar-text-muted);
  padding: 8px 20px 6px;
}
.ar-sidebar-divider {
  height: 1px;
  background: var(--ar-border);
  margin: 12px 20px;
}
.ar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ar-text-muted);
  transition: all .15s;
  border-left: 3px solid transparent;
}
.ar-nav-item:hover {
  background: var(--ar-surface-2);
  color: var(--ar-text);
}
.ar-nav-item.active {
  color: var(--ar-accent);
  border-left-color: var(--ar-accent);
  background: color-mix(in srgb, var(--ar-accent) 8%, transparent);
}
.ar-nav-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: .7;
}
.ar-nav-item.active .ar-nav-icon {
  opacity: 1;
}
.ar-nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ar-nav-home {
  color: var(--ar-accent);
  opacity: .6;
  flex-shrink: 0;
}
.ar-nav-binding {
  cursor: default;
  opacity: .6;
  font-size: 12px;
}

/* ── Content Area ── */
.ar-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  transition: opacity .2s, transform .2s;
}
.ar-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.ar-page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ar-text);
  margin: 0;
}
.ar-page-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ar-text-muted);
  background: var(--ar-surface-2);
  padding: 3px 10px;
  border-radius: 8px;
}

/* ── Placeholder / Empty ── */
.ar-placeholder {
  text-align: center;
  padding: 48px 24px;
  color: var(--ar-text-muted);
  font-size: 14px;
  background: var(--ar-surface);
  border-radius: 12px;
  border: 1px dashed var(--ar-border);
}
.ar-empty-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--ar-text-muted);
  text-align: center;
}
.ar-empty-icon { opacity: .3; margin-bottom: 16px; }
.ar-empty-page h3 { margin: 0 0 8px; font-weight: 600; }
.ar-empty-page p { margin: 0; font-size: 14px; }

/* ── Error State ── */
.ar-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  text-align: center;
  color: var(--ar-text-muted);
}
.ar-error-icon { opacity: .3; margin-bottom: 16px; color: #ef4444; }
.ar-error-state h2 { font-size: 24px; font-weight: 700; margin: 0 0 8px; color: var(--ar-text); }
.ar-error-state p { margin: 0 0 24px; font-size: 14px; }

/* ── Passcode Gate ── */
.ar-passcode-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--ar-bg, #0f0f0f);
}
.ar-passcode-card {
  background: var(--ar-surface, #1a1a1a);
  border: 1px solid var(--ar-border, #2a2a2a);
  border-radius: 16px;
  padding: 40px 36px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.ar-back-link {
  color: var(--ar-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.ar-back-link:hover { text-decoration: underline; }

/* ── Summary Cards ── */
.ar-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.ar-summary-card {
  background: var(--ar-surface);
  border: 1px solid var(--ar-border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}
.ar-summary-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--ar-accent);
  line-height: 1;
  margin-bottom: 4px;
}
.ar-summary-label {
  font-size: 12px;
  color: var(--ar-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* ── Widgets ── */
.ar-widget-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.ar-widget {
  background: var(--ar-surface);
  border: 1px solid var(--ar-border);
  border-radius: 12px;
  overflow: hidden;
}
.ar-widget-full {
  grid-column: 1 / -1;
}
.ar-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ar-border);
}
.ar-widget-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ar-text);
}
.ar-widget-count {
  font-size: 12px;
  color: var(--ar-text-muted);
  font-weight: 500;
}
.ar-widget-body {
  padding: 16px 20px;
}

/* ── Deployments Widget ── */
.ar-dep-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ar-dep-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--ar-surface-2);
  font-size: 13px;
}
.ar-dep-status { flex-shrink: 0; }
.ar-dep-status.running { color: #22c55e; }
.ar-dep-status.stopped { color: #6b7280; }
.ar-dep-name { flex: 1; font-weight: 500; }
.ar-dep-time { color: var(--ar-text-muted); font-size: 12px; }

/* ── State Widget ── */
.ar-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.ar-state-card {
  background: var(--ar-surface-2);
  border-radius: 8px;
  padding: 12px 14px;
}
.ar-state-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.ar-state-status { font-size: 11px; text-transform: uppercase; color: var(--ar-text-muted); letter-spacing: .5px; }
.ar-state-count { font-size: 20px; font-weight: 800; color: var(--ar-accent); margin-top: 6px; }
.ar-state-takt { font-size: 11px; color: var(--ar-text-muted); }

/* ── Events Widget ── */
.ar-events-table {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ar-events-row {
  display: grid;
  grid-template-columns: 100px 120px 1fr 90px;
  gap: 12px;
  padding: 8px 4px;
  font-size: 13px;
  border-bottom: 1px solid var(--ar-border);
  align-items: center;
}
.ar-events-row:last-child { border-bottom: none; }
.ar-events-header {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ar-text-muted);
}
.ar-event-type {
  font-weight: 600;
  color: var(--ar-accent);
  font-size: 12px;
}
.ar-event-detail {
  color: var(--ar-text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ar-event-time {
  color: var(--ar-text-muted);
  font-size: 11px;
  text-align: right;
}

/* ── Monitor Tiles ── */
.ar-monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.ar-monitor-tile {
  background: var(--ar-surface);
  border: 1px solid var(--ar-border);
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.ar-monitor-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.ar-monitor-ok { border-color: #22c55e40; }
.ar-monitor-late { border-color: #ef444460; background: #ef444408; }
.ar-monitor-hooked { border-color: #f59e0b40; background: #f59e0b08; }
.ar-monitor-idle { border-color: var(--ar-border); }
.ar-monitor-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ar-text);
}
.ar-monitor-status {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.ar-monitor-ok .ar-monitor-status { color: #22c55e; }
.ar-monitor-late .ar-monitor-status { color: #ef4444; }
.ar-monitor-hooked .ar-monitor-status { color: #f59e0b; }
.ar-monitor-idle .ar-monitor-status { color: #6b7280; }
.ar-monitor-count {
  font-size: 32px;
  font-weight: 800;
  color: var(--ar-accent);
  line-height: 1;
  margin-bottom: 6px;
}
.ar-monitor-takt {
  font-size: 11px;
  color: var(--ar-text-muted);
}
.ar-monitor-andon {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

/* ── Form Renderer ── */
.ar-form-container {
  max-width: 640px;
}
.ar-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.ar-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ar-form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ar-text);
}
.ar-form-input {
  background: var(--ar-surface);
  border: 1px solid var(--ar-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ar-text);
  font-family: inherit;
  transition: border-color .15s;
}
.ar-form-input:focus {
  outline: none;
  border-color: var(--ar-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ar-accent) 20%, transparent);
}
.ar-form-check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.ar-form-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}
.ar-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.ar-btn-primary {
  background: var(--ar-accent);
  color: #fff;
}
.ar-btn-primary:hover { filter: brightness(1.1); }
.ar-btn-secondary {
  background: var(--ar-surface-2);
  color: var(--ar-text);
  border: 1px solid var(--ar-border);
}
.ar-btn-secondary:hover { background: var(--ar-border); }

/* ── Table Renderer ── */
.ar-table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--ar-border);
}
.ar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ar-table thead th {
  background: var(--ar-surface);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ar-text-muted);
  border-bottom: 1px solid var(--ar-border);
}
.ar-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--ar-border);
}
.ar-table tbody tr:last-child td { border-bottom: none; }
.ar-table tbody tr:hover { background: var(--ar-surface); }
.ar-table-empty {
  text-align: center;
  color: var(--ar-text-muted);
  padding: 32px !important;
}
.ar-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.ar-status-running { background: #22c55e20; color: #22c55e; }
.ar-status-late { background: #ef444420; color: #ef4444; }
.ar-status-hooked-up { background: #f59e0b20; color: #f59e0b; }
.ar-status-stopped { background: #6b728020; color: #6b7280; }
.ar-andon-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* ── Custom / Markdown Content ── */
.ar-custom-content {
  line-height: 1.7;
  font-size: 15px;
}
.ar-markdown h1, .ar-markdown h2, .ar-markdown h3 { color: var(--ar-text); margin: 24px 0 12px; }
.ar-markdown h1 { font-size: 28px; }
.ar-markdown h2 { font-size: 22px; }
.ar-markdown h3 { font-size: 18px; }
.ar-markdown code {
  background: var(--ar-surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.ar-markdown ul { padding-left: 20px; }
.ar-markdown a { color: var(--ar-accent); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .ar-sidebar {
    position: fixed;
    top: var(--ar-topbar-h);
    left: 0;
    bottom: 0;
    z-index: 90;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .ar-sidebar.collapsed {
    width: 0;
    box-shadow: none;
  }
  .ar-content {
    padding: 16px;
  }
  .ar-summary-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .ar-widget-grid {
    grid-template-columns: 1fr;
  }
  .ar-events-row {
    grid-template-columns: 80px 100px 1fr 70px;
  }
  .ar-monitor-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* ============================================================
   Community Hub — Styles
   ============================================================ */

/* ── Shell ── */
.community-hub {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
}
.community-header {
  margin-bottom: 8px;
}
.community-header h1 {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f1f5f9;
}
.community-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 20px;
  padding-bottom: 0;
  overflow-x: auto;
}
.community-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.community-tab:hover {
  color: #f1f5f9;
  background: rgba(255,255,255,0.03);
}
.community-tab.active {
  color: #7c3aed;
  border-bottom-color: #7c3aed;
}

/* ── Toolbar ── */
.ch-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.ch-toolbar-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ch-select {
  padding: 7px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 13px;
  cursor: pointer;
}
.ch-select:focus {
  outline: none;
  border-color: #7c3aed;
}
.ch-select-sm { padding: 5px 8px; font-size: 12px; }
.ch-input {
  padding: 7px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 13px;
  min-width: 180px;
}
.ch-input:focus {
  outline: none;
  border-color: #7c3aed;
}
.ch-input-lg { font-size: 16px; padding: 10px 14px; }
.ch-textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.ch-textarea:focus {
  outline: none;
  border-color: #7c3aed;
}
.ch-textarea-lg { font-size: 14px; min-height: 300px; }

/* ── Buttons ── */
.ch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.ch-btn-primary {
  background: #7c3aed;
  color: #fff;
}
.ch-btn-primary:hover {
  background: #6d28d9;
}
.ch-btn-secondary {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.08);
}
.ch-btn-secondary:hover {
  background: rgba(255,255,255,0.1);
}
.ch-btn-danger {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}
.ch-btn-danger:hover {
  background: rgba(239,68,68,0.25);
}
.ch-btn-ghost {
  background: none;
  color: #94a3b8;
  padding: 6px 10px;
}
.ch-btn-ghost:hover {
  color: #f1f5f9;
  background: rgba(255,255,255,0.05);
}
.ch-btn-sm { padding: 5px 10px; font-size: 12px; }
.ch-btn-xs { padding: 3px 6px; font-size: 11px; }

/* ── Loading / Empty ── */
.ch-loading {
  text-align: center;
  padding: 40px;
  color: #64748b;
  font-size: 14px;
}
.ch-empty {
  text-align: center;
  padding: 60px 20px;
  color: #64748b;
}
.ch-empty h3 {
  color: #94a3b8;
  margin: 12px 0 6px;
}
.ch-empty p {
  margin-bottom: 16px;
}
.ch-muted {
  color: #64748b;
  font-size: 13px;
  padding: 12px 0;
}

/* ── Badges & Tags ── */
.ch-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: color-mix(in srgb, var(--badge-color) 15%, transparent);
  color: var(--badge-color);
  border: 1px solid color-mix(in srgb, var(--badge-color) 25%, transparent);
}
.ch-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: rgba(124,58,237,0.1);
  color: #8b5cf6;
  border: 1px solid rgba(124,58,237,0.15);
}
.ch-article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.ch-article-cat {
  font-size: 12px;
  color: #94a3b8;
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── Avatar ── */
.ch-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.ch-avatar-lg {
  width: 64px !important;
  height: 64px !important;
  font-size: 24px !important;
}

/* ── Article Cards ── */
.ch-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.ch-article-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
}
.ch-article-card:hover {
  border-color: rgba(124,58,237,0.3);
  background: rgba(255,255,255,0.05);
  transform: translateY(-2px);
}
.ch-article-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ch-article-date {
  font-size: 12px;
  color: #64748b;
}
.ch-article-title {
  font-size: 16px;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0 0 10px;
  line-height: 1.4;
}
.ch-article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 10px;
}
.ch-article-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #64748b;
}
.ch-article-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Article Detail ── */
.ch-article-detail, .ch-post-detail {
  max-width: 800px;
  margin: 0 auto;
}
.ch-article-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.ch-article-detail-actions {
  display: flex;
  gap: 8px;
}
.ch-article-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ch-article-detail-title {
  font-size: 28px;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.3;
  margin: 0 0 16px;
}
.ch-article-detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ch-author-name {
  font-weight: 600;
  color: #f1f5f9;
  font-size: 14px;
}
.ch-author-name:hover {
  color: #7c3aed;
}
.ch-article-time {
  display: block;
  font-size: 12px;
  color: #64748b;
}
.ch-article-body {
  color: #cbd5e1;
  font-size: 15px;
  line-height: 1.8;
}
.ch-article-body p { margin-bottom: 16px; }
.ch-article-body-wrap, .ch-post-body-wrap {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
}

/* ── Versions Panel ── */
.ch-versions-panel {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 24px;
}
.ch-versions-panel summary {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.ch-versions-list {
  margin-top: 12px;
}
.ch-version-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  color: #64748b;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

/* ── Forum Threads ── */
.ch-forum-threads {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ch-forum-thread {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.ch-forum-thread:hover {
  border-color: rgba(124,58,237,0.25);
  background: rgba(255,255,255,0.04);
}
.ch-forum-thread.ch-pinned {
  border-color: rgba(124,58,237,0.2);
  background: rgba(124,58,237,0.03);
}
.ch-forum-thread-votes {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}
.ch-vote-count {
  font-size: 18px;
  font-weight: 700;
  color: #94a3b8;
}
.ch-vote-count.positive { color: #22c55e; }
.ch-vote-count.negative { color: #ef4444; }
.ch-vote-label {
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ch-forum-thread-body {
  flex: 1;
  min-width: 0;
}
.ch-forum-thread-title {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ch-pin-badge, .ch-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}
.ch-pin-badge {
  background: rgba(124,58,237,0.15);
  color: #8b5cf6;
}
.ch-lock-badge {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
}
.ch-forum-thread-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
}
.ch-meta-sep {
  color: #475569;
}
.ch-forum-thread-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}
.ch-stat-box {
  text-align: center;
}
.ch-stat-num {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #e2e8f0;
}
.ch-stat-label {
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
}

/* ── Post Detail — Vote Column ── */
.ch-post-body-wrap {
  display: flex;
  gap: 20px;
}
.ch-post-vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 8px;
}
.ch-vote-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s;
}
.ch-vote-btn:hover {
  border-color: #7c3aed;
  color: #7c3aed;
  background: rgba(124,58,237,0.1);
}
.ch-vote-btn.active {
  color: #7c3aed;
  border-color: #7c3aed;
  background: rgba(124,58,237,0.15);
}
.ch-vote-sm {
  width: 26px;
  height: 26px;
}
.ch-post-score {
  font-size: 18px;
  font-weight: 700;
  color: #f1f5f9;
}
.ch-post-main {
  flex: 1;
  min-width: 0;
}
.ch-locked-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.15);
  border-radius: 8px;
  color: #ef4444;
  font-size: 13px;
  margin-top: 12px;
}

/* ── Comments ── */
.ch-comments-section {
  margin-top: 8px;
}
.ch-comments-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: #f1f5f9;
  margin-bottom: 16px;
}
.ch-comments-empty {
  text-align: center;
  padding: 24px;
  color: #64748b;
  font-size: 13px;
}
.ch-comment {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ch-comment.ch-hidden {
  opacity: 0.4;
}
.ch-comment-vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ch-comment-score {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
}
.ch-comment-main {
  flex: 1;
  min-width: 0;
}
.ch-comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.ch-rep-badge {
  font-size: 10px;
  color: #f59e0b;
  background: rgba(245,158,11,0.1);
  padding: 1px 6px;
  border-radius: 4px;
}
.ch-comment-time {
  font-size: 11px;
  color: #64748b;
}
.ch-edited {
  font-size: 11px;
  color: #64748b;
  font-style: italic;
}
.ch-comment-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s;
}
.ch-comment:hover .ch-comment-actions {
  opacity: 1;
}
.ch-comment-body {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.6;
}
.ch-comment-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.ch-comment-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ── Editor ── */
.ch-editor {
  max-width: 800px;
  margin: 0 auto;
}
.ch-editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.ch-editor-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #f1f5f9;
}
.ch-editor-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ch-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ch-form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ch-form-row {
  display: flex;
  gap: 16px;
}
.ch-form-half {
  flex: 1;
}
.ch-editor-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.ch-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
}
.ch-checkbox-label input[type="checkbox"] {
  accent-color: #7c3aed;
}

/* ── Profile ── */
.ch-profile {
  max-width: 800px;
  margin: 0 auto;
}
.ch-profile-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 24px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 14px;
  margin-bottom: 24px;
}
.ch-profile-avatar img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
}
.ch-profile-info h2 {
  font-size: 22px;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0 0 4px;
}
.ch-profile-role {
  font-size: 12px;
  color: #7c3aed;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.ch-profile-location {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #64748b;
  margin-top: 4px;
}
.ch-profile-bio {
  color: #94a3b8;
  font-size: 14px;
  margin: 8px 0;
  line-height: 1.6;
}
.ch-profile-stats-row {
  display: flex;
  gap: 20px;
  margin: 10px 0;
}
.ch-profile-stat {
  font-size: 13px;
  color: #94a3b8;
}
.ch-profile-stat strong {
  color: #f1f5f9;
  font-size: 16px;
}
.ch-profile-edit-panel {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.ch-profile-edit-panel summary {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.ch-profile-tabs h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: #f1f5f9;
  margin: 20px 0 12px;
}
.ch-contrib-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ch-contrib-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.ch-contrib-item:hover {
  border-color: rgba(124,58,237,0.2);
  background: rgba(255,255,255,0.04);
}
.ch-contrib-title {
  font-size: 14px;
  font-weight: 500;
  color: #f1f5f9;
}
.ch-contrib-meta {
  font-size: 12px;
  color: #64748b;
}

/* ── Moderation ── */
.ch-mod-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}
.ch-mod-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: #f1f5f9;
  margin-bottom: 12px;
}
.ch-mod-add-word {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.ch-report-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 8px;
}
.ch-report-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.ch-report-type {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
}
.ch-report-by {
  font-size: 12px;
  color: #94a3b8;
}
.ch-report-reason {
  font-size: 13px;
  color: #cbd5e1;
  font-style: italic;
  margin-bottom: 10px;
}
.ch-report-actions {
  display: flex;
  gap: 8px;
}
.ch-word-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 6px;
  margin-bottom: 4px;
}
.ch-word-text {
  font-size: 13px;
  color: #e2e8f0;
  flex: 1;
}
.ch-word-severity {
  font-size: 10px;
}

/* ── Audit Trail ── */
.ch-audit-timeline {
  position: relative;
  padding-left: 28px;
}
.ch-audit-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,255,255,0.05);
}
.ch-audit-item {
  position: relative;
  padding: 12px 0;
}
.ch-audit-dot {
  position: absolute;
  left: -24px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #0f172a;
}
.ch-audit-body {
  padding-left: 0;
}
.ch-audit-action {
  font-size: 14px;
  color: #cbd5e1;
}
.ch-audit-action strong {
  color: #f1f5f9;
}
.ch-audit-verb {
  color: #94a3b8;
}
.ch-audit-entity {
  color: #7c3aed;
}
.ch-audit-time {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}
.ch-audit-details {
  font-size: 11px;
  color: #475569;
  font-family: monospace;
  margin-top: 4px;
  word-break: break-all;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .ch-card-grid {
    grid-template-columns: 1fr;
  }
  .ch-forum-thread {
    flex-direction: column;
    align-items: flex-start;
  }
  .ch-forum-thread-votes {
    flex-direction: row;
    gap: 8px;
  }
  .ch-forum-thread-stats {
    flex-direction: row;
  }
  .ch-post-body-wrap {
    flex-direction: column;
  }
  .ch-post-vote-col {
    flex-direction: row;
    gap: 8px;
    padding-top: 0;
    margin-bottom: 8px;
  }
  .ch-form-row {
    flex-direction: column;
  }
  .ch-profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .ch-profile-stats-row {
    justify-content: center;
  }
  .ch-mod-layout {
    grid-template-columns: 1fr;
  }
  .ch-article-detail-title {
    font-size: 22px;
  }
}

/* ========================================================================
   PHASE 3 — MESSAGING
   ======================================================================== */

.msg-shell {
  display: flex;
  height: 100vh;
  background: var(--bg-primary);
  overflow: hidden;
}

.msg-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.msg-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.msg-sidebar-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.msg-sidebar-actions {
  display: flex;
  gap: 4px;
}

.msg-sidebar-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: all 0.15s;
  font-size: 13px;
}

.msg-sidebar-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.msg-channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.msg-ch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
  position: relative;
}

.msg-ch-item:hover {
  background: var(--bg-hover);
}

.msg-ch-item.active {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
}

.msg-ch-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-color);
  flex-shrink: 0;
}

.msg-ch-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.msg-ch-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-ch-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-ch-preview {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-ch-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.msg-ch-time {
  font-size: 10px;
  color: var(--text-tertiary);
}

.msg-unread-badge {
  background: var(--accent-color);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.msg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

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

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

.msg-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-header-info span {
  font-size: 12px;
  color: var(--text-tertiary);
}

.msg-header-actions {
  display: flex;
  gap: 4px;
}

.msg-header-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  transition: all 0.15s;
}

.msg-header-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.msg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-date-sep {
  text-align: center;
  padding: 12px 0;
  position: relative;
}

.msg-date-sep span {
  background: var(--bg-primary);
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.msg-date-sep::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--border-color);
}

.msg-bubble {
  display: flex;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.15s;
  position: relative;
  max-width: 100%;
}

.msg-bubble:hover {
  background: var(--bg-hover);
}

.msg-bubble:hover .msg-actions {
  opacity: 1;
  pointer-events: auto;
}

.msg-bubble-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-color);
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-bubble-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

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

.msg-bubble-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.msg-bubble-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.msg-bubble-time {
  font-size: 10px;
  color: var(--text-tertiary);
}

.msg-bubble-edited {
  font-size: 10px;
  color: var(--text-tertiary);
  font-style: italic;
}

.msg-bubble-content {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-primary);
  word-break: break-word;
}

.msg-bubble-content p {
  margin: 0 0 4px 0;
}

.msg-bubble-content p:last-child {
  margin-bottom: 0;
}

.msg-bubble-thread {
  margin-top: 4px;
}

.msg-bubble-thread button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--accent-color);
  padding: 2px 0;
  font-weight: 500;
}

.msg-bubble-thread button:hover {
  text-decoration: underline;
}

.msg-bubble-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.msg-attachment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--accent-color);
  cursor: pointer;
  transition: all 0.15s;
}

.msg-attachment:hover {
  background: var(--accent-bg);
}

.msg-actions {
  position: absolute;
  top: -8px;
  right: 8px;
  display: flex;
  gap: 2px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 2;
}

.msg-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  transition: all 0.1s;
}

.msg-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.msg-actions button.danger:hover {
  color: #e74c3c;
}

.msg-edit-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--accent-color);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  margin-top: 4px;
}

.msg-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.msg-edit-actions button {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  border: none;
}

.msg-edit-actions .save {
  background: var(--accent-color);
  color: #fff;
}

.msg-edit-actions .cancel {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.msg-composer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-primary);
}

.msg-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  min-height: 20px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color 0.15s;
}

.msg-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.msg-input::placeholder {
  color: var(--text-tertiary);
}

.msg-send-btn {
  background: var(--accent-color);
  color: #fff;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.msg-send-btn:hover {
  opacity: 0.85;
  transform: scale(1.05);
}

.msg-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Messaging — Thread Overlay */

.msg-thread-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: msg-slide-in 0.2s ease;
}

@keyframes msg-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.msg-thread-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.msg-thread-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.msg-thread-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
}

.msg-thread-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.msg-thread-parent {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.msg-thread-replies {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-thread-composer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.msg-thread-composer textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  min-height: 18px;
  max-height: 80px;
}

.msg-thread-composer textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

.msg-thread-composer button {
  background: var(--accent-color);
  color: #fff;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Messaging — New DM / New Channel Panels */

.msg-new-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}

.msg-new-card {
  background: var(--bg-primary);
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.msg-new-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.msg-new-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px;
}

.msg-new-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.msg-new-body input[type="text"],
.msg-new-body textarea,
.msg-new-body select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.msg-new-body input[type="text"]:focus,
.msg-new-body textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

.msg-new-body label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.msg-user-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 12px;
}

.msg-user-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.msg-user-option:hover {
  background: var(--bg-hover);
}

.msg-user-option.selected {
  background: var(--accent-bg);
}

.msg-user-option input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent-color);
}

.msg-new-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.msg-new-footer button {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.msg-new-footer .msg-btn-primary {
  background: var(--accent-color);
  color: #fff;
}

.msg-new-footer .msg-btn-primary:hover {
  opacity: 0.85;
}

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

/* Messaging — Channel Info Panel */

.msg-info-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: msg-slide-in 0.2s ease;
}

.msg-info-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.msg-info-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.msg-info-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.msg-info-section {
  margin-bottom: 20px;
}

.msg-info-section h5 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.msg-member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.msg-member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-color);
}

.msg-member-name {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
}

.msg-member-role {
  font-size: 10px;
  color: var(--text-tertiary);
  padding: 2px 6px;
  background: var(--bg-secondary);
  border-radius: 4px;
}

/* Messaging — Empty State */

.msg-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  gap: 8px;
  padding: 40px;
}

.msg-empty-icon {
  font-size: 40px;
  opacity: 0.3;
}

.msg-empty h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
}

.msg-empty p {
  margin: 0;
  font-size: 13px;
  text-align: center;
  max-width: 280px;
  line-height: 1.4;
}

/* ========================================================================
   PHASE 3 — FLOW TOOLS (Versions, Templates, Secrets, Webhooks, Import)
   ======================================================================== */

.ft-page {
  padding: 24px 28px;
  max-width: 960px;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}

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

.ft-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.ft-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ft-toolbar button {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.15s;
}

.ft-toolbar button:hover {
  background: var(--bg-hover);
}

.ft-toolbar button.primary {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.ft-toolbar button.primary:hover {
  opacity: 0.85;
}

.ft-back-btn {
  background: none !important;
  border: none !important;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.ft-back-btn:hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary);
}

.ft-filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.ft-filter-row input,
.ft-filter-row select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
}

.ft-filter-row input:focus,
.ft-filter-row select:focus {
  outline: none;
  border-color: var(--accent-color);
}

.ft-filter-row input {
  flex: 1;
  min-width: 180px;
}

/* Flow Versions — Version List */

.ft-version-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ft-version-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-primary);
  transition: all 0.15s;
}

.ft-version-card:hover {
  border-color: var(--accent-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.ft-version-number {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-color);
  min-width: 40px;
  text-align: center;
}

.ft-version-info {
  flex: 1;
  min-width: 0;
}

.ft-version-changelog {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.ft-version-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

.ft-version-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent-color);
  flex-shrink: 0;
}

.ft-version-badge.latest {
  background: var(--green-bg);
  color: var(--green);
}

.ft-version-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.ft-version-actions button {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.ft-version-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ft-version-actions button.danger:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

/* Flow Tools — Diff Panel */

.ft-diff-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}

.ft-diff-panel {
  background: var(--bg-primary);
  border-radius: 12px;
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.ft-diff-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.ft-diff-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px;
}

.ft-diff-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.ft-diff-section {
  margin-bottom: 16px;
}

.ft-diff-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ft-diff-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 12px;
}

.ft-diff-stat.added {
  background: var(--green-bg);
  color: var(--green);
}

.ft-diff-stat.removed {
  background: var(--red-bg);
  color: var(--red);
}

.ft-diff-stat.modified {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.ft-diff-stat .count {
  font-weight: 700;
  min-width: 20px;
}

.ft-diff-items {
  padding-left: 16px;
  margin-top: 4px;
}

.ft-diff-item {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 0;
}

/* Flow Tools — Template Grid */

.ft-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.ft-template-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  background: var(--bg-primary);
  transition: all 0.15s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ft-template-card:hover {
  border-color: var(--accent-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.ft-template-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.ft-template-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ft-template-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
}

.ft-template-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ft-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  border: 1px solid var(--border-color);
}

.ft-template-stats {
  font-size: 10px;
  color: var(--text-tertiary);
}

.ft-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.ft-badge.public {
  background: var(--green-bg);
  color: var(--green);
}

.ft-badge.private {
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  border: 1px solid var(--border-color);
}

/* Flow Tools — Template Detail Overlay */

.ft-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}

.ft-detail-panel {
  background: var(--bg-primary);
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.ft-detail-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.ft-detail-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px;
}

.ft-detail-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.ft-detail-body p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 12px;
}

.ft-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.ft-detail-meta span {
  font-size: 11px;
  color: var(--text-tertiary);
}

.ft-detail-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ft-detail-footer button {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.ft-detail-footer .ft-btn-primary {
  background: var(--accent-color);
  color: #fff;
}

.ft-detail-footer .ft-btn-primary:hover {
  opacity: 0.85;
}

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

/* Flow Tools — Secrets Vault Table */

.ft-table-wrap {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

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

.ft-table th,
.ft-table td {
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border-color);
}

.ft-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ft-table tr:last-child td {
  border-bottom: none;
}

.ft-table tr:hover td {
  background: var(--bg-hover);
}

.ft-secret-name {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-color);
}

.ft-secret-value {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
}

.ft-revealed {
  color: var(--text-primary) !important;
  background: var(--yellow-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.ft-table-actions {
  display: flex;
  gap: 4px;
}

.ft-table-actions button {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.ft-table-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ft-table-actions button.danger:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

/* Flow Tools — Secrets Add/Edit Overlay */

.ft-form-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}

.ft-form-panel {
  background: var(--bg-primary);
  border-radius: 12px;
  width: 440px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
}

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

.ft-form-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.ft-form-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px;
}

.ft-form-body {
  padding: 16px 20px;
}

.ft-form-body label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.ft-form-body input,
.ft-form-body textarea,
.ft-form-body select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.ft-form-body input:focus,
.ft-form-body textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

.ft-form-body .hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: -8px;
  margin-bottom: 12px;
}

.ft-form-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ft-form-footer button {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.ft-form-footer .ft-btn-primary {
  background: var(--accent-color);
  color: #fff;
}

.ft-form-footer .ft-btn-primary:hover {
  opacity: 0.85;
}

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

/* Flow Tools — Webhooks */

.ft-webhook-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ft-webhook-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg-primary);
  transition: all 0.15s;
}

.ft-webhook-card:hover {
  border-color: var(--accent-border);
}

.ft-webhook-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}

.ft-webhook-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.ft-webhook-status {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
}

.ft-webhook-status.active {
  background: var(--green-bg);
  color: var(--green);
}

.ft-webhook-status.inactive {
  background: var(--red-bg);
  color: var(--red);
}

.ft-webhook-url {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.ft-webhook-url code {
  font-size: 11px;
  background: var(--bg-secondary);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ft-webhook-url button {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all 0.15s;
  flex-shrink: 0;
}

.ft-webhook-url button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ft-webhook-meta {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.ft-webhook-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.ft-webhook-actions button {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.ft-webhook-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ft-webhook-actions button.danger:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

/* Flow Tools — Import Panel */

.ft-import-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}

.ft-import-card {
  background: var(--bg-primary);
  border-radius: 12px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
}

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

.ft-import-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.ft-import-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px;
}

.ft-import-body {
  padding: 20px;
}

.ft-import-drop {
  border: 2px dashed var(--border-color);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 16px;
}

.ft-import-drop:hover {
  border-color: var(--accent-color);
  background: var(--accent-bg);
}

.ft-import-drop.dragover {
  border-color: var(--accent-color);
  background: var(--accent-bg);
}

.ft-import-drop-icon {
  font-size: 32px;
  opacity: 0.3;
  margin-bottom: 8px;
}

.ft-import-drop p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.ft-import-drop small {
  font-size: 11px;
  color: var(--text-tertiary);
}

.ft-import-preview {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg-secondary);
  font-size: 12px;
  margin-bottom: 16px;
}

.ft-import-preview .name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.ft-import-preview .meta {
  color: var(--text-tertiary);
  font-size: 11px;
}

.ft-import-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ft-import-footer button {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.ft-import-footer .ft-btn-primary {
  background: var(--accent-color);
  color: #fff;
}

.ft-import-footer .ft-btn-primary:hover {
  opacity: 0.85;
}

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

/* Flow Tools — Empty States */

.ft-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
}

.ft-empty-icon {
  font-size: 40px;
  opacity: 0.3;
  margin-bottom: 8px;
}

.ft-empty h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
}

.ft-empty p {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  max-width: 300px;
  margin: 0 auto;
}

/* ========================================================================
   PHASE 3 — RESPONSIVE (Messaging + Flow Tools)
   ======================================================================== */

@media (max-width: 768px) {
  .msg-shell {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }
  .msg-sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .msg-thread-overlay,
  .msg-info-overlay {
    width: 100%;
  }
  .msg-composer {
    padding: 10px 12px;
  }
  .msg-messages {
    padding: 12px;
  }
  .msg-header {
    padding: 10px 14px;
  }
  .ft-page {
    padding: 16px 14px;
  }
  .ft-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .ft-toolbar {
    width: 100%;
    flex-wrap: wrap;
  }
  .ft-filter-row {
    flex-direction: column;
  }
  .ft-filter-row input {
    min-width: 0;
    width: 100%;
  }
  .ft-template-grid {
    grid-template-columns: 1fr;
  }
  .ft-version-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .ft-version-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .ft-diff-panel,
  .ft-detail-panel,
  .ft-form-panel,
  .ft-import-card {
    width: 95vw;
  }
  .ft-webhook-url code {
    font-size: 10px;
  }
  .ft-table-wrap {
    overflow-x: auto;
  }
  .ft-table {
    min-width: 500px;
  }
  .msg-new-card {
    width: 95vw;
  }
}

/* ══════════════════════════════════════════════
   SCHEDULES — Phase 4
   ══════════════════════════════════════════════ */

.sched-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}

.sched-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.sched-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.sched-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.sched-card-info {
  flex: 1;
  min-width: 0;
}
.sched-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.sched-card-flow {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.sched-card-status {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}
.sched-status-active {
  background: var(--green-bg);
  color: var(--green);
}
.sched-status-inactive {
  background: var(--red-bg);
  color: var(--red);
}

.sched-card-cron {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sched-cron-expr {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-color);
  background: none;
  padding: 0;
}
.sched-cron-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.sched-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.sched-stat {
  text-align: center;
}
.sched-stat-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.sched-stat-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}
.text-success { color: var(--green) !important; }
.text-danger { color: var(--red) !important; }

.sched-card-tz {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
}

.sched-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}
.sched-card-actions .btn-sm {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.btn-danger-ghost {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red-bg);
  cursor: pointer;
  transition: background var(--transition);
}
.btn-danger-ghost:hover {
  background: var(--red-bg);
}

/* Schedule run history */
.sched-runs-list {
  max-height: 400px;
  overflow-y: auto;
}
.sched-run-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
}
.sched-run-item:last-child { border-bottom: none; }
.sched-run-status {
  font-weight: 600;
  min-width: 70px;
}
.sched-run-time {
  color: var(--text-secondary);
  flex: 1;
}
.sched-run-duration {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.sched-run-error {
  color: var(--red);
  font-size: 0.72rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════
   THEME TOGGLE — Phase 4
   ══════════════════════════════════════════════ */

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.theme-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}
.theme-toggle-btn svg {
  width: 14px;
  height: 14px;
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg-900: #f5f5f7;
  --bg-800: #ffffff;
  --bg-700: #f9f9fb;
  --bg-600: #f0f0f3;
  --bg-500: #e4e4e7;
  --border: #d4d4d8;
  --border-hover: #a1a1aa;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-tertiary: #a1a1aa;
  --citrus: #6d28d9;
  --citrus-light: #7c3aed;
  --citrus-dark: #c2410c;
  --citrus-glow: rgba(234, 88, 12, 0.08);
  --citrus-glow-strong: rgba(234, 88, 12, 0.15);
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.08);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.06);
  --yellow: #ca8a04;
  --yellow-bg: rgba(202, 138, 4, 0.08);
  --blue: #2563eb;
  --blue-bg: rgba(37, 99, 235, 0.06);
  --accent: #6d28d9;
  --surface: #ffffff;
  --bg: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.12);
  /* Aliases */
  --bg-primary: var(--bg-800);
  --bg-secondary: var(--bg-700);
  --bg-hover: var(--bg-600);
  --border-color: var(--border);
  --accent-color: var(--citrus);
  --accent-bg: var(--citrus-glow);
  --accent-border: var(--citrus-dark);
}

/* Light theme specific overrides */
[data-theme="light"] body {
  background: var(--bg-900);
}
[data-theme="light"] .sidebar {
  background: var(--bg-800);
  border-right-color: var(--border);
}
[data-theme="light"] .nav-item:hover {
  background: var(--bg-600);
}
[data-theme="light"] .nav-item.active {
  background: var(--citrus-glow);
  color: var(--citrus);
}
[data-theme="light"] .stat-card {
  background: var(--bg-800);
  border-color: var(--border);
}
[data-theme="light"] .modal {
  background: var(--bg-800);
  border-color: var(--border);
}
[data-theme="light"] .toast {
  background: var(--bg-800);
  border-color: var(--border);
  color: var(--text-primary);
}
[data-theme="light"] .badge-draft {
  background: var(--bg-600);
  color: var(--text-secondary);
}
[data-theme="light"] .CodeMirror {
  background: var(--bg-800) !important;
  color: var(--text-primary) !important;
}
[data-theme="light"] .CodeMirror-gutters {
  background: var(--bg-700) !important;
  border-color: var(--border) !important;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: var(--bg-500);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Schedules responsive */
@media (max-width: 768px) {
  .sched-grid {
    grid-template-columns: 1fr;
  }
  .sched-card-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .sched-card-actions {
    flex-direction: column;
  }
  .sched-card-actions .btn-sm {
    width: 100%;
    justify-content: center;
  }
}

/* ══════════════════════════════════════════════
   APP TEMPLATES — Gallery, Cards, Preview
   ══════════════════════════════════════════════ */

.atpl-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}
.atpl-search {
  max-width: 400px;
}
.atpl-categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.atpl-cat-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-700);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.atpl-cat-btn:hover {
  border-color: var(--citrus);
  color: var(--text-primary);
}
.atpl-cat-btn.active {
  background: var(--citrus);
  border-color: var(--citrus);
  color: #fff;
}
.atpl-cat-count {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 4px;
}

.atpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.atpl-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 20px;
}
.atpl-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.atpl-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.atpl-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.atpl-card-info {
  flex: 1;
  min-width: 0;
}
.atpl-card-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}
.atpl-card-category {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.atpl-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.atpl-card-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.atpl-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.atpl-badge.system { background: var(--citrus)20; color: var(--citrus); }
.atpl-badge.custom { background: #6366f120; color: #6366f1; }
.atpl-badge.home { background: #22c55e20; color: #22c55e; }
.atpl-tags {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.atpl-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-600);
  color: var(--text-muted);
}

/* App Templates Preview */
.atpl-preview-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.atpl-preview-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.atpl-preview-category {
  font-size: 13px;
  color: var(--text-muted);
}
.atpl-preview-desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}
.atpl-preview-section {
  margin-bottom: 20px;
}
.atpl-preview-section h4 {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 10px;
  font-weight: 600;
}
.atpl-preview-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.atpl-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-700);
  border-radius: 8px;
  font-size: 13px;
}
.atpl-preview-item-icon {
  color: var(--text-muted);
}
.atpl-preview-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
}
.atpl-preview-item-type {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════
   PERMISSIONS — Table, Badges, Capabilities Grid
   ══════════════════════════════════════════════ */

.perm-notice {
  padding: 12px 16px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
}
.perm-table-wrap {
  overflow-x: auto;
  margin-bottom: 32px;
}
.perm-type-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}
.perm-type-badge.user { background: #0ea5e920; color: #0ea5e9; }
.perm-type-badge.team { background: #8b5cf620; color: #8b5cf6; }
.perm-preset-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: capitalize;
}
.perm-preset-badge.viewer { background: #64748b20; color: #64748b; }
.perm-preset-badge.editor { background: #22c55e20; color: #22c55e; }
.perm-preset-badge.deployer { background: #7c3aed20; color: #7c3aed; }
.perm-preset-badge.admin { background: #ef444420; color: #ef4444; }
.perm-preset-badge.custom { background: #6366f120; color: #6366f1; }
.perm-cap-count {
  font-size: 12px;
  color: var(--text-muted);
}
.perm-level-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.perm-level-badge.view { background: #64748b20; color: #64748b; }
.perm-level-badge.edit { background: #22c55e20; color: #22c55e; }
.perm-level-badge.deploy { background: #7c3aed20; color: #7c3aed; }
.perm-level-badge.admin { background: #ef444420; color: #ef4444; }

.perm-my-access {
  margin-top: 32px;
}
.perm-my-access h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.perm-caps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.perm-cap-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: monospace;
  background: var(--bg-700);
  color: var(--text-secondary);
}
.perm-cap-item.granted {
  color: #22c55e;
}
.perm-cap-item.denied {
  color: var(--text-muted);
  opacity: 0.5;
}
.perm-cap-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.perm-cap-item.granted .perm-cap-dot { background: #22c55e; }
.perm-cap-item.denied .perm-cap-dot { background: var(--text-muted); }

.perm-section {
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-700);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.perm-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.perm-section-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.perm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.perm-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-800);
  border-radius: 6px;
}
.perm-list-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ══════════════════════════════════════════════
   PRESENCE — Collaboration Indicators
   ══════════════════════════════════════════════ */

.presence-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-700);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.presence-avatars {
  display: flex;
  align-items: center;
}
.presence-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border: 2px solid var(--bg-800);
  margin-left: -8px;
  position: relative;
  cursor: default;
  transition: transform 0.2s;
}
.presence-avatar:first-child {
  margin-left: 0;
}
.presence-avatar:hover {
  transform: scale(1.15);
  z-index: 2;
}
.presence-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.presence-avatar span {
  line-height: 1;
}
.presence-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg-800);
}
.presence-overflow {
  background: var(--bg-600);
  color: var(--text-muted);
  font-size: 10px;
}
.presence-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Presence responsive */
@media (max-width: 768px) {
  .atpl-grid {
    grid-template-columns: 1fr;
  }
  .perm-caps-grid {
    grid-template-columns: 1fr;
  }
  .presence-label {
    display: none;
  }
}

/* ============================================================
   Command Palette — Cmd+K / Ctrl+K
   ============================================================ */

.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.cmd-overlay.open {
  opacity: 1;
}

.cmd-palette {
  width: 560px;
  max-width: 90vw;
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform 0.15s ease;
}
.cmd-overlay.open .cmd-palette {
  transform: translateY(0) scale(1);
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.cmd-search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}
.cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
}
.cmd-input::placeholder {
  color: var(--text-muted);
}
.cmd-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: inherit;
  line-height: 1;
}

.cmd-results {
  max-height: 340px;
  overflow-y: auto;
  padding: 6px 0;
}

.cmd-group-label {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.cmd-result {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  gap: 10px;
  transition: background 0.1s;
}
.cmd-result:hover,
.cmd-result.selected {
  background: var(--bg-700);
}
.cmd-result-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.cmd-result-text {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cmd-result-label {
  color: var(--text-primary);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-result-sublabel {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.cmd-result-type {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: capitalize;
  flex-shrink: 0;
}

.cmd-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.cmd-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-tertiary);
}
.cmd-footer kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 4px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 10px;
  font-family: inherit;
  margin-right: 3px;
}

/* Light theme overrides */
[data-theme="light"] .cmd-palette {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .cmd-input {
  color: #1a202c;
}
[data-theme="light"] .cmd-result.selected,
[data-theme="light"] .cmd-result:hover {
  background: #f7fafc;
}
[data-theme="light"] .cmd-result-label {
  color: #1a202c;
}
[data-theme="light"] .cmd-kbd,
[data-theme="light"] .cmd-footer kbd {
  background: #f7fafc;
  border-color: #e2e8f0;
}

/* ============================================================
   Breadcrumb Navigation
   ============================================================ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.breadcrumb-item {
  cursor: pointer;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.breadcrumb-item:hover {
  color: var(--citrus);
}
.breadcrumb-sep {
  color: var(--text-tertiary);
  font-size: 10px;
}
.breadcrumb-current {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================================
   Keyboard Shortcut Hint
   ============================================================ */

.sidebar-kbd-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  margin: 0 12px 8px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 12px;
  color: var(--text-muted);
}
.sidebar-kbd-hint:hover {
  background: var(--bg-600);
  border-color: var(--citrus);
  color: var(--text-secondary);
}
.sidebar-kbd-hint kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  background: var(--bg-600);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
}
[data-theme="light"] .sidebar-kbd-hint {
  background: #f7fafc;
  border-color: #e2e8f0;
}
[data-theme="light"] .sidebar-kbd-hint:hover {
  background: #edf2f7;
}
[data-theme="light"] .sidebar-kbd-hint kbd {
  background: #edf2f7;
  border-color: #e2e8f0;
}

/* ── Search Page ── */
.search-page { max-width: 860px; margin: 0 auto; padding: 2rem 1rem; }
.search-page-header h1 { display: flex; align-items: center; gap: .5rem; font-size: 1.5rem; margin: 0; }
.search-page-subtitle { color: var(--text-secondary); margin: .25rem 0 1.5rem; font-size: .9rem; }

.search-page-bar { margin-bottom: 1rem; }
.search-page-input-wrap {
  display: flex; align-items: center; gap: .75rem;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 12px; padding: .75rem 1rem; transition: border-color .15s;
}
.search-page-input-wrap:focus-within { border-color: var(--accent); }
.search-page-input-wrap input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 1rem; color: var(--text-primary);
}
.search-page-input-wrap input::placeholder { color: var(--text-secondary); }
.search-page-kbd {
  font-size: .7rem; padding: 2px 6px; border-radius: 4px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-secondary); font-family: inherit;
}

.search-page-filters {
  display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.search-filter-btn {
  display: flex; align-items: center; gap: .35rem; padding: .4rem .75rem;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-secondary);
  font-size: .8rem; cursor: pointer; transition: all .15s;
}
.search-filter-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.search-filter-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* View-all link in sidebar */
.search-view-all {
  padding: .5rem .75rem; font-size: .75rem; color: var(--accent);
  cursor: pointer; border-bottom: 1px solid var(--border);
}
.search-view-all:hover { text-decoration: underline; }

/* Loading */
.search-loading { text-align: center; padding: 3rem; color: var(--text-secondary); }

/* Empty state */
.search-empty { text-align: center; padding: 3rem 1rem; color: var(--text-secondary); }
.search-empty svg { opacity: .3; margin-bottom: .5rem; }
.search-empty h3 { color: var(--text-primary); margin: .5rem 0 .25rem; }
.search-empty p { font-size: .9rem; }

.search-tips {
  display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem;
}
.search-tip {
  display: flex; align-items: center; gap: .35rem; padding: .35rem .75rem;
  border-radius: 8px; background: var(--bg-secondary); font-size: .8rem;
  color: var(--text-secondary);
}

/* Summary */
.search-summary {
  font-size: .85rem; color: var(--text-secondary); margin-bottom: 1rem;
}

/* Groups */
.search-group { margin-bottom: 1.5rem; }
.search-group-header {
  display: flex; align-items: center; gap: .5rem; font-size: .85rem;
  font-weight: 600; color: var(--text-secondary); margin-bottom: .5rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.search-group-count {
  background: var(--bg-tertiary); border-radius: 10px;
  padding: 1px 8px; font-size: .7rem; font-weight: 500;
}
.search-group-items { display: flex; flex-direction: column; gap: .25rem; }

/* Result card */
.search-result-card {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-radius: 10px;
  background: var(--bg-secondary); cursor: pointer;
  transition: background .15s, transform .1s;
}
.search-result-card:hover { background: var(--bg-tertiary); transform: translateX(2px); }
.search-result-card-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent); flex-shrink: 0;
}
.search-result-card-body { flex: 1; min-width: 0; }
.search-result-card-title {
  font-weight: 600; font-size: .9rem; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-result-card-sub {
  font-size: .78rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-result-card-meta {
  display: flex; align-items: center; gap: .5rem; flex-shrink: 0;
}
.search-result-status {
  font-size: .7rem; padding: 2px 8px; border-radius: 6px;
  font-weight: 500; text-transform: capitalize;
}
.search-status-active, .search-status-published { background: color-mix(in srgb, #22c55e 15%, transparent); color: #22c55e; }
.search-status-draft { background: color-mix(in srgb, #eab308 15%, transparent); color: #eab308; }
.search-status-deployed { background: color-mix(in srgb, #3b82f6 15%, transparent); color: #3b82f6; }
.search-status-failed { background: color-mix(in srgb, #ef4444 15%, transparent); color: #ef4444; }
.search-status-inactive, .search-status-disabled { background: color-mix(in srgb, #94a3b8 15%, transparent); color: #94a3b8; }
.search-result-time { font-size: .72rem; color: var(--text-secondary); white-space: nowrap; }

/* Recent searches */
.search-recent { max-width: 500px; }
.search-recent-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: .5rem;
}
.search-recent-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem .75rem; border-radius: 8px;
  transition: background .15s;
}
.search-recent-item:hover { background: var(--bg-secondary); }
.search-recent-link {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  color: var(--text-primary); font-size: .88rem; flex: 1;
}
.search-recent-remove {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 1rem; opacity: 0; transition: opacity .15s;
  padding: .25rem .5rem;
}
.search-recent-item:hover .search-recent-remove { opacity: 1; }
.search-recent-remove:hover { color: var(--text-primary); }

/* Light mode overrides */
[data-theme="light"] .search-result-card { background: #fff; border: 1px solid var(--border); }
[data-theme="light"] .search-result-card:hover { background: #f8fafc; }
[data-theme="light"] .search-result-card-icon { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ── System Health Monitor ── */
.health-page { max-width: 1000px; margin: 0 auto; padding: 2rem 1rem; }
.health-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.health-header h1 { display: flex; align-items: center; gap: .5rem; font-size: 1.5rem; margin: 0; }
.health-subtitle { color: var(--text-secondary); margin: .25rem 0 0; font-size: .9rem; }
.health-controls { display: flex; align-items: center; gap: .5rem; }
.health-interval {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 6px; padding: .35rem .5rem; color: var(--text-primary);
  font-size: .8rem; cursor: pointer;
}
.health-toggle-btn {
  display: flex; align-items: center; gap: .3rem; padding: .35rem .65rem;
  border-radius: 6px; border: 1px solid var(--border); background: var(--bg-secondary);
  color: var(--text-secondary); font-size: .8rem; cursor: pointer; transition: all .15s;
}
.health-toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.health-loading {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  padding: 4rem; color: var(--text-secondary); font-size: .9rem;
}
.health-loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.health-error { text-align: center; padding: 3rem; color: var(--text-secondary); }
.health-error h3 { color: var(--text-primary); }

/* Banner */
.health-banner {
  display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem;
  border-radius: 12px; margin-bottom: 1.5rem;
}
.health-banner-healthy { background: color-mix(in srgb, #22c55e 8%, var(--bg-secondary)); border: 1px solid color-mix(in srgb, #22c55e 25%, transparent); }
.health-banner-degraded { background: color-mix(in srgb, #eab308 8%, var(--bg-secondary)); border: 1px solid color-mix(in srgb, #eab308 25%, transparent); }
.health-banner-unhealthy { background: color-mix(in srgb, #ef4444 8%, var(--bg-secondary)); border: 1px solid color-mix(in srgb, #ef4444 25%, transparent); }
.health-status-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.health-banner-text { display: flex; flex-direction: column; gap: .15rem; }
.health-banner-text strong { font-size: 1rem; color: var(--text-primary); }
.health-banner-text span { font-size: .8rem; color: var(--text-secondary); }

/* Stat cards */
.health-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1.5rem; }
.health-stat-card {
  display: flex; align-items: center; gap: .75rem; padding: 1rem;
  border-radius: 10px; background: var(--bg-secondary); border: 1px solid var(--border);
}
.health-stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.health-stat-value { font-weight: 700; font-size: 1.1rem; color: var(--text-primary); white-space: nowrap; }
.health-stat-label { font-size: .75rem; color: var(--text-secondary); }

/* Grid panels */
.health-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1.5rem; }
.health-panel {
  padding: 1.25rem; border-radius: 12px;
  background: var(--bg-secondary); border: 1px solid var(--border);
}
.health-panel h3 {
  display: flex; align-items: center; gap: .5rem; font-size: .9rem;
  margin: 0 0 .75rem; color: var(--text-primary);
}

/* Rows */
.health-rows { display: flex; flex-direction: column; }
.health-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .4rem 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  font-size: .85rem;
}
.health-row:last-child { border-bottom: none; }
.health-row-label { color: var(--text-secondary); }
.health-row-value { color: var(--text-primary); font-weight: 500; text-align: right; }
.health-mono { font-family: 'SF Mono', Monaco, monospace; font-size: .78rem; }

/* Badges */
.health-badge { font-size: .72rem; padding: 2px 8px; border-radius: 6px; font-weight: 500; }
.health-badge-ok { background: color-mix(in srgb, #22c55e 15%, transparent); color: #22c55e; }
.health-badge-warn { background: color-mix(in srgb, #eab308 15%, transparent); color: #eab308; }
.health-badge-err { background: color-mix(in srgb, #ef4444 15%, transparent); color: #ef4444; }

/* Memory bar */
.health-mem-bar {
  height: 8px; border-radius: 4px; background: var(--bg-tertiary);
  overflow: hidden; margin-bottom: .35rem;
}
.health-mem-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.health-mem-label { font-size: .78rem; color: var(--text-secondary); margin-bottom: .75rem; }

/* Footer */
.health-footer {
  text-align: center; font-size: .78rem; color: var(--text-secondary);
  padding-top: 1rem; border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
  .health-cards { grid-template-columns: 1fr 1fr; }
  .health-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .health-cards { grid-template-columns: 1fr; }
}

/* Light mode */
[data-theme="light"] .health-panel { background: #fff; }
[data-theme="light"] .health-stat-card { background: #fff; }
[data-theme="light"] .health-banner-healthy { background: color-mix(in srgb, #22c55e 5%, #fff); }
[data-theme="light"] .health-banner-degraded { background: color-mix(in srgb, #eab308 5%, #fff); }