/* =========================================
   SafeGTM — Design System v2
   Light-first with dark/system theme support
   ========================================= */

/* ── Light Theme (Default) — SafePaaS Brand ── */
:root {
  /* Surfaces — lavender gray page, white cards */
  --bg:             #F3F2F7;
  --bg-card:        #ffffff;
  --bg-card-hover:  #eceaf2;
  --bg-input:       #ffffff;
  --bg-sidebar:     #ffffff;
  --bg-topbar:      #ffffff;
  --bg-overlay:     rgba(0, 0, 0, 0.35);
  --bg-code:        #eceaf2;

  /* Borders */
  --border:         rgba(0, 0, 0, 0.10);
  --border-light:   rgba(0, 0, 0, 0.20);
  --border-focus:   #58889D;

  /* Text */
  --text:           #000000;
  --text-secondary: #333333;
  --text-muted:     rgba(0, 0, 0, 0.55);
  --text-dim:       rgba(0, 0, 0, 0.35);
  --text-inverse:   #ffffff;

  /* Brand — Steel Blue (trust/authority) */
  --primary:        #58889D;
  --primary-hover:  #56859C;
  --primary-bg:     rgba(88, 136, 157, 0.08);
  --primary-border: rgba(88, 136, 157, 0.25);

  /* Accent — Olive Green (CTA/action) */
  --accent:         #80A14A;
  --accent-hover:   #97B657;
  --accent-bg:      rgba(128, 161, 74, 0.08);

  /* Semantic */
  --success:        #80A14A;
  --success-bg:     rgba(128, 161, 74, 0.08);
  --success-border: rgba(128, 161, 74, 0.25);
  --warning:        #E8A838;
  --warning-bg:     rgba(232, 168, 56, 0.08);
  --warning-border: rgba(232, 168, 56, 0.25);
  --danger:         #CC3366;
  --danger-bg:      rgba(204, 51, 102, 0.08);
  --danger-border:  rgba(204, 51, 102, 0.25);
  --info:           #58889D;
  --info-bg:        rgba(88, 136, 157, 0.08);
  --info-border:    rgba(88, 136, 157, 0.25);

  /* Layout */
  --sidebar-w:      248px;
  --topbar-h:       56px;

  /* Shape — SafePaaS radius scale */
  --radius:         8px;
  --radius-lg:      20px;
  --radius-xl:      35px;
  --radius-full:    999px;

  /* Elevation — clean single-layer shadows */
  --shadow-xs:      0 0 6px 0 rgba(0, 0, 0, 0.08);
  --shadow:         0 0 10px 0 rgba(0, 0, 0, 0.10);
  --shadow-md:      0 2px 12px 0 rgba(0, 0, 0, 0.12);
  --shadow-lg:      0 4px 20px 0 rgba(0, 0, 0, 0.12);
  --shadow-xl:      0 8px 30px 0 rgba(0, 0, 0, 0.16);

  /* Motion */
  --transition:     0.15s ease;
  --transition-slow: 0.25s ease;
}

/* ── Dark Theme — SafePaaS Brand (Navy) ────── */
[data-theme="dark"] {
  --bg:             #1A1A2E;
  --bg-card:        #222240;
  --bg-card-hover:  #2A2A4A;
  --bg-input:       #2A2A4A;
  --bg-sidebar:     #222240;
  --bg-topbar:      #222240;
  --bg-overlay:     rgba(0, 0, 0, 0.6);
  --bg-code:        #2A2A4A;

  --border:         rgba(243, 242, 247, 0.10);
  --border-light:   rgba(243, 242, 247, 0.20);
  --border-focus:   #7ABED6;

  --text:           #F3F2F7;
  --text-secondary: #d5d4e0;
  --text-muted:     rgba(243, 242, 247, 0.55);
  --text-dim:       rgba(243, 242, 247, 0.35);

  --primary:        #7ABED6;
  --primary-hover:  #58889D;
  --primary-bg:     rgba(122, 190, 214, 0.10);
  --primary-border: rgba(122, 190, 214, 0.25);

  --accent:         #97B657;
  --accent-hover:   #80A14A;
  --accent-bg:      rgba(151, 182, 87, 0.10);

  --success:        #97B657;
  --success-bg:     rgba(151, 182, 87, 0.10);
  --success-border: rgba(151, 182, 87, 0.25);
  --warning:        #F0B84A;
  --warning-bg:     rgba(240, 184, 74, 0.10);
  --warning-border: rgba(240, 184, 74, 0.25);
  --danger:         #E05588;
  --danger-bg:      rgba(224, 85, 136, 0.10);
  --danger-border:  rgba(224, 85, 136, 0.25);
  --info:           #7ABED6;
  --info-bg:        rgba(122, 190, 214, 0.10);
  --info-border:    rgba(122, 190, 214, 0.25);

  --shadow-xs:      0 0 6px 0 rgba(0, 0, 0, 0.20);
  --shadow:         0 0 10px 0 rgba(0, 0, 0, 0.25);
  --shadow-md:      0 2px 12px 0 rgba(0, 0, 0, 0.30);
  --shadow-lg:      0 4px 20px 0 rgba(0, 0, 0, 0.35);
  --shadow-xl:      0 8px 30px 0 rgba(0, 0, 0, 0.40);
}

/* System preference fallback (when theme="system") */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg:             #1A1A2E;
    --bg-card:        #222240;
    --bg-card-hover:  #2A2A4A;
    --bg-input:       #2A2A4A;
    --bg-sidebar:     #222240;
    --bg-topbar:      #222240;
    --bg-overlay:     rgba(0, 0, 0, 0.6);
    --bg-code:        #2A2A4A;
    --border:         rgba(243, 242, 247, 0.10);
    --border-light:   rgba(243, 242, 247, 0.20);
    --border-focus:   #7ABED6;
    --text:           #F3F2F7;
    --text-secondary: #d5d4e0;
    --text-muted:     rgba(243, 242, 247, 0.55);
    --text-dim:       rgba(243, 242, 247, 0.35);
    --primary:        #7ABED6;
    --primary-hover:  #58889D;
    --primary-bg:     rgba(122, 190, 214, 0.10);
    --primary-border: rgba(122, 190, 214, 0.25);
    --accent:         #97B657;
    --accent-hover:   #80A14A;
    --accent-bg:      rgba(151, 182, 87, 0.10);
    --success:        #97B657;
    --success-bg:     rgba(151, 182, 87, 0.10);
    --success-border: rgba(151, 182, 87, 0.25);
    --warning:        #F0B84A;
    --warning-bg:     rgba(240, 184, 74, 0.10);
    --warning-border: rgba(240, 184, 74, 0.25);
    --danger:         #E05588;
    --danger-bg:      rgba(224, 85, 136, 0.10);
    --danger-border:  rgba(224, 85, 136, 0.25);
    --info:           #7ABED6;
    --info-bg:        rgba(122, 190, 214, 0.10);
    --info-border:    rgba(122, 190, 214, 0.25);
    --shadow-xs:      0 0 6px 0 rgba(0, 0, 0, 0.20);
    --shadow:         0 0 10px 0 rgba(0, 0, 0, 0.25);
    --shadow-md:      0 2px 12px 0 rgba(0, 0, 0, 0.30);
    --shadow-lg:      0 4px 20px 0 rgba(0, 0, 0, 0.35);
    --shadow-xl:      0 8px 30px 0 rgba(0, 0, 0, 0.40);
  }
}

/* ── Auth FOUC Prevention ──────────────────── */
/* When token exists (data-auth="pending"), hide login & sidebar until JS confirms */
[data-auth="pending"] #login-page { display: none !important; }
[data-auth="none"] #sidebar,
[data-auth="none"] #topbar { display: none !important; }

/* Auth loading indicator — centered spinner while verifying session */
#auth-loader {
  display: none;
  position: fixed;
  inset: 0;
  justify-content: center;
  align-items: center;
  background: var(--bg);
  z-index: 9999;
}
[data-auth="pending"] #auth-loader { display: flex; }
[data-auth="pending"] #auth-loader .spinner { width: 32px; height: 32px; }

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

html {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  height: 100%;
  font-family: 'Nacelle', 'Montserrat', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition-slow), color var(--transition-slow);
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 0.875rem; }
img { max-width: 100%; }

/* ── Layout ────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-slow), background var(--transition-slow);
  z-index: 100;
  overflow: hidden;
}
#sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
  height: 100%;
}

.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}
.brand-logo-white { display: none; }
[data-theme="dark"] .brand-logo-color { display: none !important; }
[data-theme="dark"] .brand-logo-white { display: block !important; }
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .brand-logo-color { display: none !important; }
  [data-theme="system"] .brand-logo-white { display: block !important; }
}
/* brand-text removed — logo-only sidebar header */

.nav-links {
  list-style: none;
  padding: 8px;
  flex: 1;
  overflow-y: auto;
}
.nav-links li { margin-bottom: 1px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}
.nav-link:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}
.nav-link.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 12px;
}

/* Nav section labels */
.nav-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  opacity: 0.7;
  list-style: none;
  margin-top: 4px;
}
.nav-section-label:first-child { margin-top: 0; }
.nav-section-toggle {
  cursor: pointer;
  transition: opacity 0.15s;
  user-select: none;
}
.nav-section-toggle:hover { opacity: 1; }
.nav-toggle-icon {
  font-size: 8px;
  transition: transform 0.2s;
  display: inline-block;
}
.nav-section-collapsed .nav-toggle-icon {
  transform: rotate(-90deg);
}

.badge {
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}
.badge.hidden { display: none; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.btn-logout {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: 2px 6px; margin-left: auto; border-radius: var(--radius);
}
.btn-logout:hover { color: var(--danger); background: var(--bg-input); }
.user-avatar-sm {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary-bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; flex-shrink: 0;
}

/* Profile dropdown menu */
.profile-menu { position: relative; margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--border); }
.profile-trigger {
  display: flex; align-items: center; gap: 8px; background: none; border: 1px solid transparent;
  color: var(--text); cursor: pointer; padding: 4px 8px; border-radius: var(--radius); transition: background 0.15s;
}
.profile-trigger:hover { background: var(--bg-input); }
.profile-menu.open .profile-trigger { background: var(--bg-input); border-color: var(--border); }
.caret { font-size: 0.6rem; color: var(--text-muted); transition: transform 0.15s; }
.profile-menu.open .caret { transform: rotate(180deg); }
.profile-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px; z-index: 1000;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); display: none;
}
.profile-menu.open .profile-dropdown { display: block; }
.profile-dropdown-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.profile-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.profile-dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px; border: none;
  background: none; color: var(--text); font-size: 0.8125rem; cursor: pointer; text-align: left;
}
.profile-dropdown-item:hover { background: var(--bg-input); }
.profile-dropdown-danger { color: var(--danger); }
.profile-dropdown-danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }

/* Main */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#topbar {
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-topbar);
  flex-shrink: 0;
  transition: background var(--transition-slow);
}
#topbar h1 {
  font-size: 1rem;
  font-weight: 800;
  flex: 1;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px;
}
.theme-toggle button {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: all var(--transition);
  line-height: 1;
}
.theme-toggle button:hover {
  color: var(--text);
  background: var(--bg);
}
.theme-toggle button.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  transition: background var(--transition-slow);
}
/* Login page fills entire viewport — break out of #content padding + overflow */
#login-page {
  margin: -24px;
  padding: 0;
  overflow: hidden;
}

/* ── Buttons — SafePaaS Brand ─────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow-xs);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled, .btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-primary {
  background: var(--accent, var(--success));
  border-color: var(--accent, var(--success));
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-primary:hover {
  background: var(--accent-hover, #97B657);
  border-color: var(--accent-hover, #97B657);
}
.btn-primary:active {
  background: #6E8E3E;
  transform: scale(0.97);
}
.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.btn-success:hover { background: var(--accent-hover, #97B657); border-color: var(--accent-hover, #97B657); }
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.btn-danger:hover { opacity: 0.9; }
.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}
.btn-warning:hover { opacity: 0.9; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; text-transform: none; letter-spacing: normal; }
.btn-full { width: 100%; justify-content: center; }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  text-transform: none;
  letter-spacing: normal;
}
.btn-ghost:hover {
  background: var(--bg-card-hover);
  box-shadow: none;
}
.btn-outline-primary {
  background: transparent;
  border: 2px solid var(--accent, var(--success));
  color: var(--accent, var(--success));
  text-transform: none;
  letter-spacing: normal;
}
.btn-outline-primary:hover {
  background: var(--accent, var(--success));
  color: white;
}
.btn-outline-danger {
  background: transparent;
  border-color: var(--danger-border);
  color: var(--danger);
  text-transform: none;
  letter-spacing: normal;
}
.btn-outline-danger:hover {
  background: var(--danger-bg);
}
/* Button loading state */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 6px;
  border-radius: var(--radius);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.icon-btn:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

/* ── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
input[type="url"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-size: 0.875rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}
textarea { resize: vertical; min-height: 80px; }

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
  width: auto;
  min-width: 160px;
  padding: 7px 12px;
}

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Stat Cards ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.stat-card:hover {
  box-shadow: var(--shadow);
}
.stat-card .stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}
.stat-card.primary  { border-left: 3px solid var(--primary); }
.stat-card.success  { border-left: 3px solid var(--success); }
.stat-card.warning  { border-left: 3px solid var(--warning); }
.stat-card.danger   { border-left: 3px solid var(--danger); }
.stat-card.info     { border-left: 3px solid var(--info); }
.stat-card.primary .stat-value  { color: var(--primary); }
.stat-card.success .stat-value  { color: var(--success); }
.stat-card.warning .stat-value  { color: var(--warning); }
.stat-card.danger .stat-value   { color: var(--danger); }
.stat-card.info .stat-value     { color: var(--info); }

/* ── Tables ─────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
thead {
  background: var(--bg-card-hover);
}
th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-secondary);
}
tbody tr {
  transition: background var(--transition);
}
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }

/* Clickable table rows */
tr[data-action] { cursor: pointer; }
tr[data-action]:hover { background: var(--primary-bg); }

/* ── Status Pills ──────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.01em;
  line-height: 1.6;
}
.pill-active, .pill-approved, .pill-completed, .pill-connected, .pill-running {
  background: var(--success-bg);
  color: var(--success);
}
.pill-pending, .pill-waiting, .pill-draft {
  background: var(--warning-bg);
  color: var(--warning);
}
.pill-failed, .pill-rejected, .pill-error, .pill-disconnected {
  background: var(--danger-bg);
  color: var(--danger);
}
.pill-inactive, .pill-paused {
  background: var(--bg-card-hover);
  color: var(--text-muted);
}
.pill-high   { background: var(--danger-bg);  color: var(--danger); }
.pill-medium { background: var(--warning-bg); color: var(--warning); }
.pill-low    { background: var(--info-bg);    color: var(--info); }

/* ── Tier Badges ───────────────────────────── */
.tier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.75rem;
}
.tier-1 { background: var(--primary-bg); color: var(--primary); }
.tier-2 { background: var(--warning-bg); color: var(--warning); }
.tier-3 { background: var(--bg-card-hover); color: var(--text-muted); }

/* ── Score Bar ─────────────────────────────── */
.score-bar {
  width: 72px;
  height: 5px;
  background: var(--bg-card-hover);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
}
.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ── Grid Layouts ──────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 1024px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Detail View ───────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.detail-item {}
.detail-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.detail-value {
  font-size: 0.875rem;
  color: var(--text);
}

/* ── Section Headers ───────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ── Empty State ───────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.6;
}
.empty-state p { font-size: 0.875rem; }

/* ── Modal ─────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
#modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.2s ease;
}
#modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
#modal-header h3 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
#modal-body { padding: 24px; }
#modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ── Toast ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.3s ease;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.3s ease;
}
.toast-success { background: var(--success); color: white; }
.toast-error   { background: var(--danger); color: white; }
.toast-info    { background: var(--primary); color: white; }
@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Login — Split Layout ─────────────────── */
.login-split {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Left panel — brand gradient */
.login-brand-panel {
  flex: 1;
  background: linear-gradient(180deg, #96bfd0 0%, #58889D 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}
.login-brand-panel::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}
.login-brand-panel::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 350px;
  height: 350px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  pointer-events: none;
}
.login-brand-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
}
.login-brand-logo {
  height: 40px;
  width: auto;
  margin-bottom: 40px;
  opacity: 0.95;
}
.login-brand-headline {
  font-size: 2.5rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 20px 0;
}
.login-brand-sub {
  font-size: 1.0625rem;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
  margin: 0 0 40px 0;
  font-weight: 400;
}
.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9375rem;
  font-weight: 500;
}
.login-feature-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  font-size: 1rem;
  flex-shrink: 0;
}
.login-brand-footer {
  position: absolute;
  bottom: 30px;
  left: 60px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Right panel — form */
.login-form-panel {
  flex: 0 0 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  background: var(--bg);
}
.login-form-content {
  width: 100%;
  max-width: 380px;
}
.login-logo {
  margin-bottom: 30px;
}
.login-logo-img {
  height: 40px;
  width: auto;
}
.login-form-content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 5px 0;
  color: var(--text);
  letter-spacing: -0.01em;
}
.login-form-content .text-muted { margin-bottom: 30px; }
.login-form-content .form-group { text-align: left; }
.login-form-content .btn-primary { margin-top: 10px; }
.remember-me {
  margin-top: -4px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-muted);
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
#google-signin-btn {
  display: flex;
  justify-content: center;
}

/* Login responsive — stack on mobile */
@media (max-width: 860px) {
  .login-split { flex-direction: column; }
  .login-brand-panel {
    padding: 40px 30px;
    min-height: auto;
  }
  .login-brand-headline { font-size: 1.75rem; }
  .login-brand-features { display: none; }
  .login-brand-footer { display: none; }
  .login-form-panel {
    flex: 1 1 auto;
    padding: 40px 30px;
  }
}

/* ── Utilities ─────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 0.8125rem; }
.text-error { color: var(--danger); font-size: 0.8125rem; margin-top: 12px; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-sm { font-size: 0.75rem; }
.text-xs { font-size: 0.6875rem; }
.text-right { text-align: right; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.nowrap { white-space: nowrap; }

/* ── Loading Spinner ───────────────────────── */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* toggle-switch styles consolidated below (line ~1444) */

/* ── Code Editor ───────────────────────────── */
textarea.code-editor {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  min-height: 200px;
  resize: vertical;
  background: var(--bg-code);
  tab-size: 2;
}

/* ── Tab Bar ───────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-bar button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab-bar button:hover { color: var(--text); }
.tab-bar button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ── Collapsible Sections ─────────────────── */
.app-category.collapsed .collapse-body { display: none; }
.app-category.collapsed .collapse-icon { transform: rotate(-90deg); }
.collapse-icon { font-size: 0.65rem; color: var(--text-muted); }

/* ── Pill Selector (Multi-Select) ──────────── */
.pill-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.pill-selector .pill-option {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  transition: all var(--transition);
  user-select: none;
}
.pill-selector .pill-option.selected {
  background: var(--primary-bg);
  border-color: var(--primary-border);
  color: var(--primary);
}
.pill-selector .pill-option:hover {
  border-color: var(--border-light);
}

/* ── Section Divider ───────────────────────── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
  padding-top: 24px;
}

/* ── Accordion (Details/Summary) ───────────── */
details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
details summary {
  padding: 12px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  background: var(--bg);
}
details summary:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}
details summary::before {
  content: '›';
  font-size: 1rem;
  font-weight: 600;
  transition: transform var(--transition);
  width: 16px;
  text-align: center;
  color: var(--text-dim);
}
details[open] summary::before {
  transform: rotate(90deg);
}
details summary::-webkit-details-marker { display: none; }
details > div, details > pre, details > p {
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* ── Pre / Code blocks ─────────────────────── */
pre {
  background: var(--bg-code);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}

/* ── Confidence / Progress Bar ─────────────── */
.confidence-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-card-hover);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.confidence-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ── Agent Cards Grid ──────────────────────── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.agent-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ── Integration Cards Grid ────────────────── */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
/* ── Conversation History ──────────────────── */
.conversation-block {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 0.8125rem;
  line-height: 1.6;
}
.conversation-block.assistant {
  background: var(--primary-bg);
  border-left: 3px solid var(--primary);
}
.conversation-block.user {
  background: var(--bg);
  border-left: 3px solid var(--border-light);
}
.conversation-block .role-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ── Email Preview (Approvals) ─────────────── */
.email-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 780px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}
.email-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.email-field {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  font-size: 0.8125rem;
}
.email-field-label {
  color: var(--text-dim);
  font-weight: 500;
  min-width: 60px;
  flex-shrink: 0;
}
.email-field-value {
  color: var(--text);
}
.email-subject {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 8px;
}
.email-body {
  padding: 24px;
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* ── Bar Chart ─────────────────────────────── */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 8px 0;
}
.bar-chart-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.bar-chart-bar {
  width: 100%;
  max-width: 32px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
  transition: height 0.3s ease;
  min-height: 2px;
}
.bar-chart-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

/* ── Page-level Action Bar ─────────────────── */
.page-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.page-action-bar h2 {
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ── 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-light); }

/* ── Focus Visible (Accessibility) ─────────── */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    height: 100%;
    transform: translateX(-100%);
  }
  #sidebar:not(.collapsed) {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  #content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .agents-grid,
  .integrations-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar input, .filter-bar select { width: 100%; }
}

/* ── Execution Timeline ───────────────────── */
.execution-timeline {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.timeline-step {
  display: flex;
  gap: 14px;
  min-height: 56px;
}
.timeline-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 32px;
}
.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
}
.timeline-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  min-height: 20px;
}
.timeline-completed .timeline-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.timeline-active .timeline-dot {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  animation: pulse-ring 1.5s ease-in-out infinite;
}
.timeline-failed .timeline-dot {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(88, 136, 157, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(88, 136, 157, 0); }
}
.timeline-content {
  padding-bottom: 16px;
  flex: 1;
  min-width: 0;
}
.timeline-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 32px;
}
.timeline-detail {
  font-size: 0.78rem;
  line-height: 1.5;
  margin-top: 2px;
}

/* ── Conversation blocks ─────────────────── */
.conversation-block {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 0.82rem;
  line-height: 1.6;
}
.conversation-block.user {
  background: var(--bg);
  border: 1px solid var(--border);
}
.conversation-block.assistant {
  background: color-mix(in srgb, var(--primary) 6%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
}
.role-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  color: var(--text-muted);
}

/* ── Toggle Switch ─────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Integration Card ─────────────────────── */
.integration-card-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}
.integration-card-controls .toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.integration-card-controls .toggle-group .toggle-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.toggle-label-on  { color: var(--success); }
.toggle-label-off { color: var(--text-dim); }
.integration-card-controls .pill-selector {
  margin-top: 0;
  flex: 1;
  justify-content: flex-end;
}
.integration-card-controls .pill-selector .pill-option {
  font-size: 0.6875rem;
  padding: 3px 10px;
}
.pill-option.mode-auto.selected {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}
.pill-option.mode-approval.selected {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}
.integration-disabled { opacity: 0.5; }
.integration-disabled .integration-card-controls { pointer-events: none; opacity: 0.5; }

/* ── Type-Specific Integration Cards ─────── */
.intg-card {
  transition: border-color var(--transition), box-shadow var(--transition);
}
.intg-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.intg-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.intg-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.intg-card-meta {
  flex: 1;
  min-width: 0;
}
.intg-card-name {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.intg-card-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}
.intg-card-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}
.intg-stat {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.intg-health {
  display: flex;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 4px;
  margin-bottom: 8px;
}
.intg-card-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}
.intg-card-controls .toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.intg-card-controls .toggle-group .toggle-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.intg-card-controls .pill-selector {
  margin-top: 0;
  flex: 1;
  justify-content: flex-end;
}
.intg-card-controls .pill-selector .pill-option {
  font-size: 0.6875rem;
  padding: 3px 10px;
}
.intg-disabled { opacity: 0.5; }
.intg-disabled .intg-card-controls { pointer-events: none; opacity: 0.5; }

/* ── Agent List ──────────────────────────── */
.agent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.agent-list-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-color: var(--primary);
}
.agent-list-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.agent-list-info { flex: 1; min-width: 0; }
.agent-list-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-list-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.agent-list-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.agent-meta-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-muted);
}
.agent-meta-stat {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.agent-list-chevron {
  font-size: 1.2rem;
  color: var(--text-muted);
}

/* ── Agent Detail Header ─────────────────── */
.agent-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ── Agent Performance Bar ───────────────── */
.agent-perf-bar {
  display: flex;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.agent-perf-item {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-right: 1px solid var(--border);
}
.agent-perf-item:last-child { border-right: none; }
.agent-perf-val {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.agent-perf-lbl {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Agent Capability Warnings ────────────── */
.agent-warnings {
  background: color-mix(in srgb, var(--warning) 8%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--border));
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.agent-warnings-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--warning);
  margin-bottom: 6px;
}
.agent-warning-item {
  font-size: 0.78rem;
  color: var(--text);
  padding: 3px 0 3px 18px;
  position: relative;
}
.agent-warning-item::before {
  content: '\2022';
  position: absolute;
  left: 4px;
  color: var(--warning);
}

/* ── Agent Collapsible Sections ──────────── */
.agent-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.agent-section-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}
.agent-section-toggle:hover { background: var(--bg); }
.agent-section-icon { font-size: 1rem; }
.agent-section-title {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.agent-section-chevron {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.agent-section.collapsed .agent-section-chevron { transform: rotate(-90deg); }
.agent-section-body {
  padding: 0 18px 16px;
  transition: max-height 0.2s;
}
.agent-section.collapsed .agent-section-body {
  display: none;
}

/* ── Agent Forms ─────────────────────────── */
.agent-form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 0;
}
.agent-form-field {
  margin-bottom: 12px;
}
.agent-form-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.agent-form-field input,
.agent-form-field textarea,
.agent-form-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.84rem;
  font-family: inherit;
}
.agent-form-field textarea { resize: vertical; }

/* ── Agent Prompt (view mode) ────────────── */
.agent-prompt {
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--text);
  padding: 16px 20px;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ── Agent Prompt Editor (edit mode) ─────── */
.agent-prompt-editor {
  width: 100%;
  min-height: 200px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  resize: vertical;
}

/* ── Agent Checkbox Grid/List ────────────── */
.agent-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}
.agent-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-checkbox-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.agent-checkbox-card:hover { background: var(--bg); }
.agent-checkbox-card.selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, var(--bg-card));
}
.agent-checkbox-card input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
}
.agent-checkbox-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1rem;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .agent-list-meta { display: none; }
  .agent-perf-bar { flex-wrap: wrap; }
  .agent-perf-item { min-width: 33%; }
  .agent-checkbox-grid { grid-template-columns: 1fr; }
  .agent-form-row { flex-direction: column; gap: 0; }
}

/* ── Integration Detail Page ─────────────── */
.intg-detail-header {
  margin-bottom: 20px;
}
.intg-back-link {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 12px;
  transition: color 0.15s;
}
.intg-back-link:hover { color: var(--primary); }
.intg-detail-title {
  display: flex;
  align-items: center;
  gap: 14px;
}
.intg-detail-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.intg-detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .intg-detail-grid { grid-template-columns: 1fr; }
}
.intg-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.intg-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.intg-health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.intg-health-stat {
  text-align: center;
  padding: 8px;
  background: var(--bg);
  border-radius: var(--radius);
}
.intg-health-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.intg-health-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.intg-config-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.intg-config-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.intg-config-row:last-child { border-bottom: none; }
.intg-config-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.intg-config-value {
  font-size: 0.78rem;
  color: var(--text);
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intg-feed-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.intg-feed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius);
}
.intg-feed-url {
  flex: 1;
  font-size: 0.78rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intg-feed-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.intg-feed-remove:hover { color: var(--danger); }
.intg-add-item {
  display: flex;
  gap: 8px;
  align-items: center;
}
.intg-add-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.82rem;
}
.intg-meta-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
}
.intg-meta-list code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
}
.intg-danger-zone {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}

/* ── Signal Loop: Review Cards ────────────── */
.review-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-card {
  padding: 16px 20px;
  border-left: 3px solid var(--warning);
  transition: border-color 0.15s ease;
}

.review-card:hover {
  border-left-color: var(--primary);
}

.review-card-body {
  display: flex;
  align-items: center;
  gap: 20px;
}

.review-card-main {
  flex: 1;
  min-width: 0;
}

.review-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 4px;
}

.review-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.review-card-routing {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.review-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Signal Loop: Threshold Controls ─────── */
.threshold-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.threshold-item label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text);
  margin-bottom: 6px;
}

.threshold-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.threshold-control input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.threshold-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.threshold-control input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.threshold-value {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
  min-width: 52px;
  text-align: right;
}

/* ── Signal Loop: Status pills ───────────── */
.pill-running { background: var(--success-bg); color: var(--success); }
.pill-inactive { background: var(--bg-input); color: var(--text-muted); }
.pill-pending_review, .pill-pendingreview { background: var(--warning-bg); color: var(--warning); }
.pill-dispatched { background: var(--info-bg); color: var(--info); }
.pill-dismissed { background: var(--bg-input); color: var(--text-dim); }
.pill-ignored { background: var(--bg-input); color: var(--text-dim); }

/* ── Signal Loop: Section headers ────────── */
.section-header .badge-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--warning);
  color: var(--text-inverse);
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  padding: 0 6px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ── Quota Ring ────────────────────────────── */
.quota-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.quota-ring svg { position: absolute; top: 0; left: 0; }
.quota-ring-value {
  position: relative;
  z-index: 1;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.quota-ring-label {
  position: absolute;
  bottom: -14px;
  font-size: 0.55rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Status Dot ───────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-pulse {
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Integration Monitoring ───────────────── */
.integration-health-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 0;
  font-size: 0.75rem;
}
.integration-health-bar .health-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}
.integration-health-bar .health-stat strong {
  color: var(--text);
  font-weight: 600;
}

/* Monitoring section in detail modal */
.monitoring-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.monitoring-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.monitoring-card .mon-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.monitoring-card .mon-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}
.monitoring-card .mon-sub {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* API log row status */
.api-log-success { color: var(--success); }
.api-log-error { color: var(--danger); }
.api-log-timeout { color: var(--warning); }

/* ── Workflow Editor ───────────────────────── */
.wf-editor {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.wf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  gap: 12px;
  flex-shrink: 0;
}
.wf-toolbar-left { display: flex; align-items: center; gap: 12px; }
.wf-toolbar-right { display: flex; align-items: center; gap: 8px; }
.wf-zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 6px;
}
.wf-zoom-btn { padding: 2px 6px !important; min-width: 24px; font-size: 1rem; line-height: 1; }
.wf-zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.wf-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.wf-zoom-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
}
.wf-zoom-label { min-width: 36px; text-align: center; font-variant-numeric: tabular-nums; }
.wf-toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.wf-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.wf-palette {
  width: 140px;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  padding: 8px;
  overflow-y: auto;
  flex-shrink: 0;
}
.wf-palette-section { margin-bottom: 12px; }
.wf-palette-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
.wf-palette-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: grab;
  font-size: 0.8rem;
  transition: background 0.15s;
  margin-bottom: 2px;
}
.wf-palette-item:hover { background: var(--bg-input); }
.wf-palette-item:active { cursor: grabbing; }
.wf-palette-icon { font-size: 1rem; width: 20px; text-align: center; }
.wf-palette-text { font-weight: 500; }

.wf-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}
.wf-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

.wf-config {
  width: 280px;
  border-left: 1px solid var(--border);
  background: var(--bg-card);
  overflow-y: auto;
  flex-shrink: 0;
}
.wf-conflict-banner {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.78rem;
}
.wf-conflict-item { padding: 2px 0; }
.wf-conflict-error { color: var(--danger); }
.wf-conflict-warn { color: var(--warning); }
.wf-config-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 16px;
}
.wf-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.wf-config-body {
  padding: 12px;
}
.wf-config-body .form-group { margin-bottom: 10px; }
.wf-config-body label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-input-sm {
  padding: 5px 8px;
  font-size: 0.82rem;
}

/* SVG node styling */
.wf-node { cursor: pointer; }
.wf-node:hover .wf-node-body { filter: brightness(1.05); }
.wf-node-selected .wf-node-body { filter: brightness(1.08); }
.wf-node-label { pointer-events: none; }
.wf-node-subtitle { pointer-events: none; }
.wf-node-icon { pointer-events: none; }

/* Ports */
.wf-port {
  fill: var(--bg-card);
  stroke: var(--text-muted);
  stroke-width: 2;
  cursor: crosshair;
  transition: fill 0.15s;
}
.wf-port:hover {
  fill: var(--primary);
  stroke: var(--primary);
  r: 9;
}
.wf-port-false {
  stroke: var(--danger);
}

/* Edges */
.wf-edge {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
  cursor: pointer;
  transition: stroke 0.15s;
}
.wf-edge:hover {
  stroke: var(--primary);
  stroke-width: 2.5;
}
.wf-edge-label {
  font-size: 10px;
  fill: var(--text-muted);
  text-anchor: middle;
  pointer-events: none;
}
.wf-temp-edge {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-dasharray: 6 3;
  pointer-events: none;
}

/* ── Schedule Picker ────────────────────────── */
.schedule-picker .form-group { margin-bottom: 10px; }
.schedule-day-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.schedule-day-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.schedule-day-btn input[type="checkbox"] { display: none; }
.schedule-day-btn span {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--bg-input);
  color: var(--text-muted);
  transition: all 0.15s;
  user-select: none;
}
.schedule-day-btn input:checked + span {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.schedule-day-btn:hover span {
  border-color: var(--primary);
}
.schedule-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-input));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 8px;
}
.schedule-preview-icon { font-size: 1rem; }

/* ── Variable Picker (Workflow Editor) ─────── */
.wf-var-insert-btn {
  margin-top: 4px;
  font-size: 0.75rem;
  padding: 3px 8px;
  color: var(--primary);
  border: 1px dashed var(--primary-border);
  background: var(--primary-bg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.wf-var-insert-btn:hover {
  background: color-mix(in srgb, var(--primary) 15%, var(--bg-input));
  border-style: solid;
}
.wf-var-picker {
  max-height: 360px;
  overflow-y: auto;
}
.wf-var-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  letter-spacing: 0.04em;
}
.wf-var-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius);
  transition: background 0.12s;
}
.wf-var-option:hover {
  background: var(--bg-card-hover);
}
.wf-var-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}
.wf-var-code {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
}

/* Connections section in config panel */
.wf-connections-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.wf-connections-section > label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Notification Bell + Dropdown ──────────── */
.notif-bell-wrap {
  position: relative;
}
.notif-bell-btn {
  position: relative;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-bell-btn svg {
  width: 18px;
  height: 18px;
}
.notif-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: #fff;
  background: var(--danger);
  border-radius: 10px;
  pointer-events: none;
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: -40px;
  width: 360px;
  max-height: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 36px rgba(0,0,0,.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.notif-dropdown-header .btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0;
  font-weight: 500;
}
.notif-dropdown-header .btn-link:hover {
  text-decoration: underline;
}
.notif-dropdown-body {
  overflow-y: auto;
  max-height: 380px;
  flex: 1;
}
.notif-empty {
  padding: 24px 14px;
  text-align: center;
}
.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:hover {
  background: var(--bg-input);
}
.notif-item.unread {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.notif-item.unread:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.notif-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  margin-top: 2px;
}
.notif-icon.info    { background: color-mix(in srgb, var(--info) 15%, transparent);    color: var(--info); }
.notif-icon.success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.notif-icon.warning { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.notif-icon.error   { background: color-mix(in srgb, var(--danger) 15%, transparent);  color: var(--danger); }
.notif-content {
  flex: 1;
  min-width: 0;
}
.notif-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-msg {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-time {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 3px;
}
.notif-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 8px;
}

/* ── Workflow Timeline ─────────────────────── */
.workflow-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 0;
}
.timeline-step {
  display: flex;
  gap: 16px;
  position: relative;
  padding-bottom: 4px;
}
.timeline-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 24px;
  flex-shrink: 0;
}
.timeline-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  z-index: 1;
}
.timeline-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  margin: 4px 0;
  min-height: 20px;
}
.timeline-content {
  flex: 1;
  padding: 6px 12px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 4px;
}

/* ── Print ─────────────────────────────────── */
@media print {
  #sidebar, #topbar, #toast-container { display: none !important; }
  #content { padding: 0; overflow: visible; }
  .btn { display: none; }
}

/* =========================================================
   Workflow Editor v2 — SafePaaS Brand Design
   ========================================================= */

/* ── Full-screen overlay ───────────────────── */
.wfe {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ── Top Bar (56px) ────────────────────────── */
.wfe-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.wfe-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.wfe-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.wfe-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.wfe-back-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--primary);
}
.wfe-topbar-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.wfe-topbar-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wfe-topbar-info {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.wfe-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.wfe-status-active {
  background: var(--success-bg);
  color: var(--success);
}
.wfe-status-paused {
  background: var(--warning-bg);
  color: var(--warning);
}
.wfe-status-draft {
  background: var(--bg);
  color: var(--text-muted);
}
.wfe-tb-btn {
  padding: 6px 12px !important;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 8px;
  transition: all var(--transition);
}
.wfe-tb-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-card));
}
.wfe-tb-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}
.wfe-save-btn {
  padding: 7px 22px !important;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.wfe-save-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(0,0,0,0.16);
  transform: translateY(-1px);
}
.wfe-save-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* ── Body Layout ───────────────────────────── */
.wfe-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Left Palette ─────────────────────────── */
.wfe-palette {
  width: 220px;
  min-width: 140px;
  max-width: 360px;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.wfe-pal-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}
.wfe-pal-search input {
  width: 100%;
  padding: 6px 28px 6px 10px;
  font-size: 0.78rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}
.wfe-pal-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 12%, transparent);
}
.wfe-pal-search-clear {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 4px;
  border-radius: 3px;
  display: none;
}
.wfe-pal-search-clear.visible { display: block; }
.wfe-pal-search-clear:hover { color: var(--text); background: var(--bg-card-hover); }
.wfe-pal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 12px;
}
.wfe-pal-section {
  margin-bottom: 10px;
}
.wfe-pal-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
  letter-spacing: 0.08em;
  padding: 4px 4px 4px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
.wfe-pal-label:hover { color: var(--text); }
.wfe-pal-chevron {
  font-size: 0.6rem;
  transition: transform 0.15s ease;
  color: var(--text-muted);
}
.wfe-pal-section.collapsed .wfe-pal-chevron { transform: rotate(-90deg); }
.wfe-pal-section.collapsed .wfe-pal-items { display: none; }
.wfe-pal-items { }
.wfe-pal-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: grab;
  font-size: 0.78rem;
  transition: all var(--transition);
  margin-bottom: 1px;
  border: 1px solid transparent;
}
.wfe-pal-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.wfe-pal-item:active {
  cursor: grabbing;
  transform: scale(0.97);
}
.wfe-pal-item.filtered-out { display: none; }
.wfe-pal-section.filtered-out { display: none; }
.wfe-pal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.wfe-pal-text {
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}
.wfe-pal-status {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 3px;
  flex-shrink: 0;
}
.wfe-pal-status-text {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
}

/* ── Resize Handles ──────────────────────────── */
.wfe-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  transition: background 0.15s;
}
.wfe-resize-handle:hover,
.wfe-resize-handle.dragging {
  background: var(--primary);
  opacity: 0.4;
}
.wfe-resize-handle::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -3px; right: -3px;
}

/* ── Sidebar Toggle ──────────────────────────── */
.wfe-sb-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%) translateX(100%);
  width: 20px;
  height: 48px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  z-index: 3;
  transition: all var(--transition);
}
.wfe-sb-toggle:hover { background: var(--bg-card-hover); color: var(--text); }

/* ── Context Menu ────────────────────────────── */
.wfe-ctx-menu {
  position: fixed;
  z-index: 1100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 160px;
  padding: 4px 0;
  font-size: 0.82rem;
}
.wfe-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: inherit;
  font-family: inherit;
}
.wfe-ctx-item:hover { background: var(--bg-card-hover); }
.wfe-ctx-item.danger { color: var(--danger); }
.wfe-ctx-item.danger:hover { background: var(--danger-bg); }
.wfe-ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }
.wfe-ctx-shortcut { margin-left: auto; font-size: 0.68rem; color: var(--text-dim, var(--text-muted)); opacity: 0.6; }

.wfe-tool-badge {
  padding: 6px 10px;
  background: color-mix(in srgb, var(--primary) 5%, var(--bg));
  border-radius: 6px;
  margin-bottom: 10px;
}
.wfe-agent-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.wfe-agent-tools .pill {
  font-size: 0.68rem;
  padding: 2px 8px;
}

/* ── I/O Tab ─────────────────────────────────── */
.wfe-io-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.06em;
  margin: 12px 0 6px;
}
.wfe-io-section-title:first-child { margin-top: 0; }
.wfe-io-var {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 5px;
  margin-bottom: 2px;
  transition: background var(--transition);
  cursor: pointer;
}
.wfe-io-var:hover { background: var(--bg-card-hover); }
.wfe-io-var-name {
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 500;
}
.wfe-io-var-code {
  font-size: 0.68rem;
  font-family: monospace;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg));
  padding: 1px 6px;
  border-radius: 3px;
}
.wfe-io-var-code:hover { background: color-mix(in srgb, var(--primary) 16%, var(--bg)); }
.wfe-io-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.wfe-io-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

/* ── Run History Tab ─────────────────────────── */
.wfe-step-hist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background var(--transition);
}
.wfe-step-hist-item:hover { background: var(--bg-card-hover); }
.wfe-step-hist-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.wfe-step-hist-meta {
  flex: 1;
  min-width: 0;
}
.wfe-step-hist-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.wfe-step-hist-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.wfe-step-hist-expand {
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: monospace;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}

/* ── Canvas ────────────────────────────────── */
.wfe-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}
.wfe-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  background: var(--bg);
}

/* Zoom controls — bottom-left */
.wfe-zoom-ctrl {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  backdrop-filter: blur(8px);
}
.wfe-zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition);
}
.wfe-zoom-btn:hover {
  background: var(--bg-card-hover);
  color: var(--primary);
}
.wfe-zoom-label {
  min-width: 40px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Minimap — bottom-right */
.wfe-minimap {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 150px;
  height: 90px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  opacity: 0.9;
  backdrop-filter: blur(8px);
}
.wfe-minimap:empty {
  display: none;
}

/* ── SVG Nodes ─────────────────────────────── */
.wfe-node {
  cursor: pointer;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.08));
}
.wfe-node:hover {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
}
.wfe-node:hover .wfe-node-body {
  filter: none;
}
.wfe-node-selected {
  filter: drop-shadow(0 0 0 rgba(0,0,0,0)) drop-shadow(0 2px 8px rgba(0,0,0,0.08));
}
.wfe-node-selected .wfe-node-body {
  filter: none;
}

/* Ports */
.wfe-port {
  fill: var(--bg-card);
  stroke: var(--border);
  stroke-width: 2;
  cursor: crosshair;
  transition: all 0.15s;
  r: 6;
}
.wfe-port:hover {
  fill: var(--primary);
  stroke: var(--primary);
  r: 8;
}
.wfe-port-false {
  stroke: var(--danger);
}
.wfe-port-false:hover {
  fill: var(--danger);
  stroke: var(--danger);
}

/* Edges */
.wfe-edge {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
  stroke-linecap: round;
  cursor: pointer;
  transition: stroke 0.15s, stroke-width 0.15s;
}
.wfe-edge:hover {
  stroke: var(--primary);
  stroke-width: 2.5;
}
.wfe-edge-label {
  font-size: 10px;
  font-weight: 600;
  fill: var(--text-muted);
  text-anchor: middle;
  pointer-events: none;
}
.wfe-edge-label-yes {
  fill: var(--accent);
}
.wfe-edge-label-no {
  fill: var(--danger);
}
.wfe-temp-edge {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-dasharray: 8 4;
  stroke-linecap: round;
  pointer-events: none;
}

/* ── Right Sidebar (320px) ─────────────────── */
.wfe-sidebar {
  width: 320px;
  min-width: 240px;
  max-width: 480px;
  border-left: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  transition: width 0.2s ease, min-width 0.2s ease, padding 0.2s ease, border 0.2s ease;
}
.wfe-sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  border-left: none !important;
  overflow: hidden;
}
.wfe-sb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  text-align: center;
}

/* Sidebar header */
.wfe-sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--primary) 6%, var(--bg-card));
  border-top: 3px solid var(--primary);
}
.wfe-sb-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.wfe-sb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1rem;
  flex-shrink: 0;
}
.wfe-sb-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wfe-sb-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.wfe-sb-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.8rem;
  transition: all var(--transition);
  flex-shrink: 0;
}
.wfe-sb-close:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

/* Sidebar tabs */
.wfe-sb-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.wfe-sb-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.wfe-sb-tab:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 4%, var(--bg-card));
}
.wfe-sb-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Sidebar body */
.wfe-sb-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}
.wfe-sb-body .form-group {
  margin-bottom: 12px;
}
.wfe-sb-body label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Sidebar footer */
.wfe-sb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
.wfe-sb-test {
  color: var(--primary) !important;
  border: 1px solid var(--primary-border) !important;
  background: var(--primary-bg) !important;
}
.wfe-sb-test:hover {
  background: color-mix(in srgb, var(--primary) 15%, var(--bg-card)) !important;
}
.wfe-sb-delete {
  color: var(--danger) !important;
  border: 1px solid var(--danger-border) !important;
  background: var(--danger-bg) !important;
}
.wfe-sb-delete:hover {
  background: color-mix(in srgb, var(--danger) 15%, var(--bg-card)) !important;
}

/* ── Sidebar Form Inputs ───────────────────── */
.wfe-input,
.wfe-select,
.wfe-textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 0.82rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  outline: none;
}
.wfe-input:focus,
.wfe-select:focus,
.wfe-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.wfe-textarea {
  resize: vertical;
  min-height: 60px;
}
.wfe-select {
  cursor: pointer;
}

.wfe-section-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}
.wfe-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--primary-bg);
  border: 1px solid var(--primary-border);
  font-size: 0.78rem;
  color: var(--text);
  margin-top: 8px;
}

/* Connection rows */
.wfe-conn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.wfe-conn-del {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background var(--transition);
}
.wfe-conn-del:hover {
  background: var(--danger-bg);
}

/* I/O tab */
.wfe-io-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.wfe-io-row:last-child {
  border-bottom: none;
}
.wfe-io-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.wfe-io-code {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
}

/* Agent cards in sidebar */
.wfe-agent-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
}
.wfe-agent-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.wfe-agent-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.wfe-agent-card.selected {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.wfe-agent-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.wfe-agent-info {
  flex: 1;
  min-width: 0;
}
.wfe-agent-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wfe-agent-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wfe-agent-check {
  color: var(--accent);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Delay presets */
.wfe-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.wfe-preset-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}
.wfe-preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.wfe-preset-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Audit Log Panel (slide-out from right) ── */
.wfe-audit-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.wfe-audit-panel.open {
  transform: translateX(0);
}
.wfe-audit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.wfe-audit-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.8rem;
  transition: all var(--transition);
}
.wfe-audit-close:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}
.wfe-audit-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.wfe-audit-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 24px;
}

/* Run cards */
.wfe-run-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
}
.wfe-run-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.wfe-run-header:hover {
  background: var(--bg-card-hover);
}
.wfe-run-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.wfe-run-meta {
  flex: 1;
  min-width: 0;
}
.wfe-run-id {
  display: block;
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.wfe-run-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.wfe-run-status {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--text-muted);
}

/* Run detail (expanded) */
.wfe-run-detail {
  border-top: 1px solid var(--border);
}
.wfe-run-detail:empty {
  border-top: none;
}

/* Step timeline in run detail */
.wfe-step-timeline {
  padding: 10px 12px;
}
.wfe-step-run {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.wfe-step-run:last-child {
  border-bottom: none;
}
.wfe-step-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.wfe-step-info {
  flex: 1;
  min-width: 0;
}
.wfe-step-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.wfe-step-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.wfe-step-type {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
}
.wfe-step-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.wfe-step-output {
  margin-top: 4px;
}
.wfe-step-output summary {
  font-size: 0.72rem;
  color: var(--primary);
  cursor: pointer;
}
.wfe-step-output pre {
  font-size: 0.7rem;
  background: var(--bg);
  padding: 8px;
  border-radius: 4px;
  margin-top: 4px;
  max-height: 150px;
  overflow: auto;
  line-height: 1.4;
}
.wfe-step-error {
  margin-top: 4px;
  padding: 6px 8px;
  border-left: 3px solid var(--danger);
  background: var(--danger-bg);
  border-radius: 0 4px 4px 0;
  font-size: 0.75rem;
  color: var(--danger);
}

/* Run summary bar */
.wfe-run-summary {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 12px;
  background: var(--bg);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 900px) {
  .wfe-palette { width: 160px; min-width: 120px; }
  .wfe-sidebar { width: 280px; min-width: 200px; }
  .wfe-audit-panel { width: 320px; }
}
@media (max-width: 700px) {
  .wfe-palette { display: none; }
  .wfe-sidebar { width: 100%; min-width: 100%; position: absolute; right: 0; top: 0; height: 100%; z-index: 5; }
  .wfe-audit-panel { width: 100%; }
  .wfe-resize-handle { display: none; }
}

/* ── Workflow Detail Page (SGM-97) ────────────────────────────────── */

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; font-size: 0.85rem; }
.breadcrumb-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-dim, var(--text-muted)); font-size: 0.75rem; }
.breadcrumb-current { color: var(--text-muted); font-weight: 400; }

/* Detail header */
.wf-detail-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.wf-detail-title { font-size: 1.25rem; font-weight: 600; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.wf-detail-desc { font-size: 0.9rem; color: var(--text-secondary, var(--text-muted)); margin: 0; cursor: pointer; }
.wf-detail-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Inline edit hints */
.edit-hint { font-size: 0.8rem; color: var(--text-dim, var(--text-muted)); opacity: 0; transition: opacity 0.15s; margin-left: 4px; }
*:hover > .edit-hint { opacity: 1; }

/* Inline edit controls */
.wf-inline-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wf-inline-input {
  padding: 6px 12px; border: 1px solid var(--primary); border-radius: 6px;
  background: var(--bg-card, #fff); color: var(--text); font-size: 0.9rem;
  outline: none; width: 100%; max-width: 500px;
}
.wf-inline-input:focus { box-shadow: 0 0 0 3px rgba(88, 136, 157, 0.15); }
.wf-inline-input-lg { font-size: 1.1rem; font-weight: 600; }
.wf-inline-select {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-card, #fff); color: var(--text); font-size: 0.85rem;
  min-width: 160px; cursor: pointer;
}
.wf-inline-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(88, 136, 157, 0.15); }
.wf-edit-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  display: block; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em;
}

/* Trigger badge */
.wf-trigger-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--bg-card, #fff);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.85rem; color: var(--text-secondary, var(--text));
  cursor: pointer; transition: border-color 0.15s;
}
.wf-trigger-badge:hover { border-color: var(--primary); }

/* Tabs */
.wf-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.wf-tab {
  padding: 10px 20px; font-size: 0.9rem; font-weight: 400;
  color: var(--text-muted); cursor: pointer;
  border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; transition: all 0.15s;
}
.wf-tab:hover { color: var(--text-secondary, var(--text)); }
.wf-tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

/* Embedded workflow graph container */
.wf-embed-container {
  position: relative; height: 380px; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; background: var(--bg-card, #fff);
}
.wfe-embed-wrap { width: 100%; height: 100%; position: relative; }
.wfe-embed-svg { width: 100%; height: 100%; }
.wfe-embed-zoom {
  position: absolute; bottom: 12px; right: 12px;
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-card, #fff); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Run card (clickable) */
.wf-run-card { cursor: pointer; padding: 14px 20px; transition: border-color 0.15s, box-shadow 0.15s; }
.wf-run-card:hover { border-color: var(--primary); box-shadow: 0 1px 6px rgba(88, 136, 157, 0.12); }

/* Step execution timeline */
.wf-step-exec { display: flex; gap: 14px; min-height: 52px; }
.wf-step-rail { display: flex; flex-direction: column; align-items: center; width: 28px; flex-shrink: 0; }
.wf-step-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.wf-step-dot-pulse { animation: wf-pulse 1.5s infinite; }
@keyframes wf-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.wf-step-line { width: 2px; flex: 1; background: var(--border); min-height: 12px; }
.wf-step-body { flex: 1; padding-bottom: 20px; min-width: 0; }
.wf-step-body-last { padding-bottom: 0; }
.wf-step-exec:last-child .wf-step-line { display: none; }
.wf-step-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; font-size: 0.9rem; }
.wf-step-duration { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); font-family: monospace; }

/* Agent response block */
.wf-agent-response {
  margin-top: 10px; padding: 14px 18px;
  background: var(--bg-input, var(--bg-card));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.wf-agent-response-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--accent); margin-bottom: 8px;
}

/* Raw output toggle */
.wf-raw-toggle { margin-top: 8px; }
.wf-raw-toggle summary {
  font-size: 0.8rem; color: var(--primary); cursor: pointer; font-weight: 500;
}
.wf-raw-toggle pre {
  font-size: 0.75rem; background: var(--bg-code, var(--bg-input));
  padding: 10px 14px; border-radius: 8px; overflow-x: auto;
  max-height: 240px; margin-top: 6px; border: 1px solid var(--border);
  font-family: monospace; color: var(--text-secondary, var(--text));
}

/* Error banner */
.wf-error-banner {
  padding: 12px 16px; background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-left: 3px solid var(--danger); border-radius: 0 8px 8px 0;
  margin-bottom: 20px; font-size: 0.85rem;
}

/* Markdown body */
.markdown-body { font-size: 0.9rem; line-height: 1.65; color: var(--text-secondary, var(--text)); }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { color: var(--text); margin: 16px 0 8px; font-weight: 600; }
.markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body h3:first-child { margin-top: 0; }
.markdown-body h1 { font-size: 1.15rem; }
.markdown-body h2 { font-size: 1.05rem; }
.markdown-body h3 { font-size: 0.95rem; }
.markdown-body p { margin: 0 0 10px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 10px; padding-left: 24px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body code {
  background: var(--bg-code, var(--bg-input)); padding: 2px 6px;
  border-radius: 4px; font-size: 0.85rem; font-family: monospace;
}
.markdown-body pre {
  background: var(--bg-code, var(--bg-input)); padding: 12px 16px;
  border-radius: 8px; overflow-x: auto; margin: 8px 0 12px;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote {
  border-left: 3px solid var(--border); padding-left: 14px;
  color: var(--text-muted); margin: 8px 0 12px;
}
.markdown-body strong { color: var(--text); font-weight: 600; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; }
.markdown-body th {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  color: var(--primary); text-align: left; padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.markdown-body td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }


/* -- Step Health Table -- */
.sh-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-card); border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.sh-table th { text-align: left; padding: 12px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); }
.sh-table td { padding: 14px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sh-table tr:last-child td { border-bottom: none; }
.sh-table tbody tr { transition: var(--transition); }
.sh-table tbody tr:hover { background: var(--bg-card-hover); }
.sh-order { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); font-size: 11px; font-weight: 700; }
.sh-step { display: inline-flex; align-items: center; gap: 8px; }
.sh-icon { width: 28px; height: 28px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.sh-name { font-weight: 600; }
.sh-subtype { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.sh-dur { display: flex; align-items: center; gap: 8px; }
.sh-bar { height: 4px; border-radius: 2px; opacity: 0.5; min-width: 4px; }
.sh-dur-text { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-fail { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sh-fail-high { color: var(--danger); font-weight: 600; }

/* ── Awareness Dashboard v3 (ApexCharts) ──────────────────────────── */

/* Loading */
.aw-loading { display: flex; justify-content: center; padding: 80px 0; }

/* KPI Strip */
.aw-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; margin-bottom: 14px; }
.aw-kpi {
  display: block; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; transition: box-shadow 0.2s, transform 0.15s;
  border-left: 3px solid var(--kc, var(--primary)); cursor: pointer; overflow: hidden;
}
.aw-kpi:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); transform: translateY(-1px); }
.aw-kpi-top { display: flex; justify-content: space-between; align-items: flex-start; }
.aw-kpi-val { font-size: 24px; font-weight: 700; line-height: 1; color: var(--kc); font-variant-numeric: tabular-nums; }
.aw-kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 5px; }
.aw-kpi-sub { font-size: 10px; color: var(--text-muted); opacity: 0.6; margin-top: 4px; }
.aw-kpi-spark { flex-shrink: 0; }

/* Cards */
.aw-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; overflow: hidden; margin-bottom: 0;
}
.aw-card-hero { margin-bottom: 14px; }
.aw-card-full { margin-bottom: 14px; }
.aw-card-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.aw-card-h h3 { font-size: 13px; font-weight: 700; color: var(--text); margin: 0; }
.aw-card-sub { font-size: 11px; color: var(--text-muted); }
.aw-link { font-size: 12px; color: var(--primary); text-decoration: none; font-weight: 500; }
.aw-link:hover { text-decoration: underline; }

/* Chart containers */
.aw-chart-hero { min-height: 300px; }
.aw-chart-md { min-height: 260px; }
.aw-chart-sm { min-height: 220px; }

/* Layout grid */
.aw-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

/* Tier badge */
.aw-tier {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 20px; border-radius: 4px; font-size: 10px; font-weight: 700;
  background: color-mix(in srgb, var(--tc) 15%, transparent);
  color: var(--tc); border: 1px solid color-mix(in srgb, var(--tc) 30%, transparent);
}

/* Score bar */
.aw-score { display: flex; align-items: center; gap: 6px; min-width: 90px; }
.aw-score-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.aw-score-fill { height: 100%; border-radius: 3px; }
.aw-score span { font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; min-width: 22px; }

/* Top accounts table */
.aw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.aw-table th {
  text-align: left; padding: 8px 10px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.aw-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.aw-table-row:hover { background: var(--primary-bg); }
.aw-table-row:last-child td { border-bottom: none; }

/* Stale assignments */
.aw-stale { margin-top: 10px; border: 1px solid var(--danger-border); border-radius: var(--radius); overflow: hidden; }
.aw-stale-head {
  padding: 8px 12px; background: var(--danger-bg); font-size: 12px; font-weight: 600; color: var(--danger);
  display: flex; align-items: center; gap: 6px;
}
.aw-stale-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  text-decoration: none; font-size: 12px; border-top: 1px solid var(--danger-border);
  transition: background 0.1s;
}
.aw-stale-row:hover { background: var(--danger-bg); }
.aw-stale-name { flex: 1; font-weight: 500; color: var(--text); }
.aw-stale-who { color: var(--text-muted); }
.aw-stale-days { font-weight: 700; color: var(--danger); min-width: 30px; text-align: right; }

/* Responsive */
@media (max-width: 1024px) {
  .aw-row { grid-template-columns: 1fr; }
  .aw-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .aw-kpis { grid-template-columns: repeat(2, 1fr); }
  .aw-kpi-val { font-size: 20px; }
  .aw-chart-hero { min-height: 220px; }
  .aw-chart-md, .aw-chart-sm { min-height: 200px; }
  .aw-table { font-size: 12px; }
  .aw-table th, .aw-table td { padding: 6px; }
}
