/* ============================================================
   Balubb Dashboard — Design System
   OKLCH colour tokens · product register · dark mode
   ============================================================ */

/* ─── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Background scale — cool-tinted near-black, seed hue 255 */
  --bg-0: oklch(0.08 0.007 255);    /* deepest: page bg */
  --bg-1: oklch(0.11 0.009 255);    /* sidebar, cards */
  --bg-2: oklch(0.14 0.010 255);    /* elevated panels */
  --bg-3: oklch(0.18 0.011 255);    /* hover fills */
  --bg-4: oklch(0.22 0.011 255);    /* input bg, active fills */
  --bg-5: oklch(0.27 0.012 255);    /* top hover */

  /* Borders */
  --border:    oklch(0.30 0.015 255 / 0.35);
  --border-md: oklch(0.42 0.018 255 / 0.55);
  --border-hi: oklch(0.55 0.022 255 / 0.75);

  /* Brand primary — indigo, anchored to seed hue 258 */
  --primary:      oklch(0.55 0.20 258);
  --primary-lo:   oklch(0.55 0.20 258 / 0.13);
  --primary-mid:  oklch(0.55 0.20 258 / 0.28);
  --primary-glow: oklch(0.55 0.20 258 / 0.40);
  --primary-text: oklch(0.75 0.13 258);   /* text on dark surface */

  /* Status colours */
  --green:      oklch(0.63 0.16 148);
  --green-lo:   oklch(0.63 0.16 148 / 0.12);
  --green-hi:   oklch(0.63 0.16 148 / 0.30);
  --yellow:     oklch(0.78 0.14 87);
  --yellow-lo:  oklch(0.78 0.14 87 / 0.12);
  --red:        oklch(0.57 0.21 25);
  --red-lo:     oklch(0.57 0.21 25 / 0.12);
  --red-hi:     oklch(0.57 0.21 25 / 0.28);
  --orange:     oklch(0.68 0.17 48);
  --orange-lo:  oklch(0.68 0.17 48 / 0.12);
  --purple:     oklch(0.72 0.11 295);
  --purple-lo:  oklch(0.72 0.11 295 / 0.12);

  /* Ink scale — WCAG AA verified: ink-2 ≥4.5:1 on bg-0/bg-1 */
  --ink-0: oklch(0.94 0.006 255);   /* body / high-emphasis */
  --ink-1: oklch(0.70 0.010 255);   /* secondary */
  --ink-2: oklch(0.55 0.010 255);   /* muted — min 4.5:1 on bg-0 */

  /* Typography */
  --font:      'Inter', system-ui, -apple-system, sans-serif;
  --font-head: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-mono: 'Space Mono', 'Menlo', monospace;

  /* Type scale (fixed, not fluid — product register) */
  --text-xs:  11px;
  --text-sm:  12px;
  --text-base:13px;
  --text-md:  14px;
  --text-lg:  16px;
  --text-xl:  20px;
  --text-2xl: 24px;

  /* Radii */
  --r-sm: 4px;
  --r:    6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Spacing */
  --gap-xs:  4px;
  --gap-sm:  8px;
  --gap-md:  12px;
  --gap-lg:  20px;
  --gap-xl:  28px;

  /* Sidebar */
  --sw: 230px;

  /* Z-index scale — semantic */
  --z-base:     0;
  --z-sticky:   100;
  --z-sidebar:  200;
  --z-dropdown: 300;
  --z-backdrop: 1000;
  --z-modal:    1001;
  --z-toast:    1100;

  /* Transition */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 300ms;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  height: 100%;
}
body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  background: var(--bg-0);
  color: var(--ink-0);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle grid backdrop */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(oklch(0.55 0.20 258 / 0.04) 1px, transparent 1px),
    linear-gradient(90deg, oklch(0.55 0.20 258 / 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* Ambient top glow over the whole page */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 40% at 60% -10%, oklch(0.55 0.20 258 / 0.09) 0%, transparent 70%);
}

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes fade-up   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modal-in  { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes toast-in  { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 0 var(--green-hi); } 50% { box-shadow: 0 0 0 4px transparent; } }
@keyframes badge-pulse { 0%,100% { box-shadow: 0 0 0 0 oklch(0.63 0.16 148 / 0.40); } 60% { box-shadow: 0 0 0 5px transparent; } }
@keyframes shimmer { 0% { background-position: -200% center; } 100% { background-position: 200% center; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Focus ──────────────────────────────────────────────────── */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ─── Spinner ────────────────────────────────────────────────── */
.spin-sm {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border-md);
  border-top-color: var(--primary-text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid var(--border-md);
  border-top-color: var(--primary-text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── Auth Overlay ───────────────────────────────────────────── */
#auth-overlay {
  display: none; position: fixed; inset: 0; z-index: var(--z-modal);
  background: oklch(0.08 0.007 255 / 0.94);
  backdrop-filter: blur(8px);
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
#auth-overlay.show { display: flex; }
.overlay-text { font-size: var(--text-md); color: var(--ink-1); }

/* ─── Login ──────────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; z-index: var(--z-backdrop);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-0);
}
.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% -8%, oklch(0.55 0.20 258 / 0.30) 0%, transparent 65%),
    radial-gradient(ellipse 40% 40% at 15% 90%, oklch(0.72 0.11 295 / 0.10) 0%, transparent 55%),
    radial-gradient(ellipse 45% 40% at 85% 88%, oklch(0.55 0.20 258 / 0.08) 0%, transparent 55%);
}
.login-wrap {
  position: relative; z-index: 1;
  width: 420px; max-width: 92vw; text-align: center;
}
.login-logo {
  font-family: var(--font-head);
  font-size: 48px; font-weight: 700; letter-spacing: -1.5px;
  line-height: 1; margin-bottom: 8px;
}
.login-logo span { color: var(--primary-text); }
.login-tagline {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 3.5px; color: var(--ink-2); margin-bottom: 36px;
}
.login-card {
  background: linear-gradient(160deg, oklch(0.155 0.012 255) 0%, var(--bg-2) 100%);
  border: 1px solid oklch(0.55 0.20 258 / 0.22);
  border-radius: var(--r-xl);
  padding: 32px;
  position: relative; overflow: hidden;
  box-shadow: 0 40px 80px oklch(0 0 0 / 0.65), 0 0 0 1px oklch(0.55 0.20 258 / 0.12), 0 0 60px oklch(0.55 0.20 258 / 0.08);
}
.login-glow {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 70%; height: 1px;
  background: linear-gradient(90deg, transparent, oklch(0.70 0.18 258), var(--purple), transparent);
  box-shadow: 0 0 20px oklch(0.55 0.20 258 / 0.50);
}
.btn-discord {
  width: 100%; padding: 13px 20px;
  background: linear-gradient(135deg, oklch(0.58 0.20 258) 0%, oklch(0.50 0.22 252) 100%);
  border: none; border-radius: var(--r-md);
  color: #fff;
  font-family: var(--font-head); font-size: var(--text-md); font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 4px 16px oklch(0.55 0.20 258 / 0.35), inset 0 1px 0 oklch(1 0 0 / 0.15);
  transition: filter var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.btn-discord:hover {
  filter: brightness(1.12);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px oklch(0.55 0.20 258 / 0.55), inset 0 1px 0 oklch(1 0 0 / 0.15);
}
.btn-discord:active { transform: translateY(0); filter: brightness(0.95); }
.login-hint {
  margin-top: 16px; font-size: var(--text-xs); color: var(--ink-2); line-height: 1.7;
}
.login-hint strong { color: var(--ink-1); }
.alert { padding: 10px 14px; border-radius: var(--r); font-size: var(--text-sm); margin-bottom: 16px; }
.alert-err { background: var(--red-lo); border: 1px solid oklch(0.57 0.21 25 / 0.3); color: var(--red); }

/* ─── App Layout ─────────────────────────────────────────────── */
#app {
  display: none; min-height: 100vh; min-height: 100dvh;
  position: relative; z-index: 1;
  width: 100%; overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sw);
  background: linear-gradient(180deg, oklch(0.115 0.009 255) 0%, oklch(0.09 0.008 255) 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--dur-base) var(--ease-out);
  box-shadow: 2px 0 24px oklch(0 0 0 / 0.25);
}

.sb-header {
  padding: 18px 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sb-logo { display: flex; align-items: center; gap: 10px; }
.sb-logo-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, oklch(0.55 0.20 258 / 0.45) 0%, oklch(0.45 0.22 255 / 0.60) 100%);
  border: 1px solid oklch(0.55 0.20 258 / 0.55);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 14px; font-weight: 700;
  color: oklch(0.92 0.08 258);
  flex-shrink: 0; letter-spacing: -0.5px;
  box-shadow: 0 0 20px oklch(0.55 0.20 258 / 0.35), 0 2px 8px oklch(0 0 0 / 0.4), inset 0 1px 0 oklch(1 0 0 / 0.18);
}
.sb-brand {
  font-family: var(--font-head); font-size: 15px; font-weight: 700;
  letter-spacing: -0.3px; line-height: 1.2;
}
.sb-brand span { color: var(--primary-text); }
.sb-sub { font-size: 10px; color: var(--ink-1); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 1px; }

/* Sidebar navigation */
.sb-nav {
  flex: 1; padding: 8px 8px;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--border-md) transparent;
}
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 99px; }

.nav-group { margin-bottom: 2px; }
.nav-label {
  display: block; padding: 10px 8px 3px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--ink-2); font-weight: 600;
  text-wrap: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 8px; border-radius: var(--r);
  background: none; border: none; cursor: pointer;
  color: var(--ink-1); font-size: var(--text-sm);
  font-family: var(--font); text-align: left;
  transition: color var(--dur-fast), background var(--dur-fast);
  position: relative;
}
.nav-item:hover { background: var(--bg-3); color: var(--ink-0); }
.nav-item.active {
  background: linear-gradient(90deg, oklch(0.55 0.20 258 / 0.18) 0%, oklch(0.55 0.20 258 / 0.06) 100%);
  color: var(--primary-text);
  box-shadow: inset 0 0 20px oklch(0.55 0.20 258 / 0.10);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 16%; bottom: 16%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, oklch(0.70 0.18 258) 0%, var(--primary) 100%);
  box-shadow: 0 0 10px var(--primary), 0 0 20px oklch(0.55 0.20 258 / 0.50);
}
.nav-icon {
  width: 15px; height: 15px; flex-shrink: 0;
  opacity: 0.55; transition: opacity var(--dur-fast);
}
.nav-item:hover .nav-icon { opacity: 0.85; }
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto; padding: 1px 6px; border-radius: 20px;
  font-size: 10px; font-weight: 700;
  background: var(--red); color: #fff;
}
.nav-badge.success {
  background: var(--green); color: #fff;
  animation: badge-pulse 2.4s ease-in-out infinite;
}

/* Bot chips in sidebar */
.sb-bot {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5px 8px; border-radius: var(--r);
  background: none; border: none; cursor: pointer;
  color: var(--ink-1); font-size: var(--text-sm);
  font-family: var(--font); text-align: left;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.sb-bot:hover { background: var(--bg-3); color: var(--ink-0); }
.sb-bot.active { background: var(--primary-lo); color: var(--primary-text); }
.sb-bot-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* Sidebar footer */
.sb-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.sb-user-info { display: flex; align-items: center; gap: 8px; }
.sb-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); border: 1.5px solid var(--border-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  overflow: hidden; flex-shrink: 0;
}
.sb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sb-user-text { flex: 1; min-width: 0; }
.sb-username {
  font-size: var(--text-sm); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ink-0);
}
.sb-role-badge {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px;
  margin-top: 1px; font-weight: 600;
}
.role-sa { background: var(--primary-lo); color: var(--primary-text); }
.role-ow { background: var(--yellow-lo); color: var(--yellow); }
.sb-logout-btn {
  padding: 5px; background: none; border: none;
  color: var(--ink-2); cursor: pointer; border-radius: var(--r);
  display: flex; transition: color var(--dur-fast);
}
.sb-logout-btn:hover { color: var(--red); }

/* Sidebar backdrop (mobile) */
#sb-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1);
  background: oklch(0 0 0 / 0.55);
}
#sb-backdrop.show { display: block; }

/* Mobile toggle */
.sb-mobile-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: calc(var(--z-sidebar) + 1);
  width: 36px; height: 36px;
  background: var(--bg-2); border: 1px solid var(--border-md);
  border-radius: var(--r); cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--ink-1); transition: background var(--dur-fast);
}
.sb-mobile-toggle:hover { background: var(--bg-3); }

/* ─── Main content ───────────────────────────────────────────── */
.main {
  margin-left: var(--sw);
  width: calc(100% - var(--sw));
  padding: var(--gap-xl) 32px;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  box-sizing: border-box;
  overflow-x: hidden;
  min-width: 0;
}

/* Pages */
.page { display: none; }
.page.active {
  display: block;
  animation: fade-up var(--dur-base) var(--ease-out);
}

.page-inner {
  max-width: 1360px;          /* Kontrollierte Breite auf UltraWide */
}

/* Page header */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: var(--gap-md);
  margin-bottom: var(--gap-xl);
  max-width: 1360px; width: 100%;
}
.page-title {
  font-family: var(--font-head); font-size: 32px;
  font-weight: 700; letter-spacing: -0.9px; line-height: 1.1;
  text-wrap: balance;
  background: linear-gradient(135deg, var(--ink-0) 0%, oklch(0.82 0.06 258) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-sub { font-size: var(--text-sm); color: var(--ink-2); margin-top: 4px; letter-spacing: 0.1px; }

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--gap-md);
  max-width: 1360px; width: 100%;
}
.section-title {
  font-family: var(--font-head); font-size: var(--text-xs); font-weight: 700;
  color: var(--ink-2); text-transform: uppercase; letter-spacing: 1.8px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::before {
  content: '';
  display: block;
  width: 3px; height: 11px;
  background: linear-gradient(180deg, oklch(0.70 0.18 258) 0%, var(--primary) 100%);
  border-radius: 1.5px;
  box-shadow: 0 0 6px oklch(0.55 0.20 258 / 0.50);
  flex-shrink: 0;
}

/* ─── KPI Cards ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-md); margin-bottom: var(--gap-xl);
  max-width: 1360px; width: 100%;
}
.kpi-grid.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid.kpi-3 .kpi-value { font-size: 44px; }

.kpi-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 22px;
  transition: border-color var(--dur-base), box-shadow var(--dur-base), transform var(--dur-fast) var(--ease-out);
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), oklch(0.72 0.11 295), transparent 85%);
  opacity: 0.80;
  pointer-events: none;
}
.kpi-card::after {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(135deg, oklch(0.55 0.20 258 / 0.07) 0%, transparent 55%);
  pointer-events: none;
}
.kpi-card:hover {
  border-color: var(--border-md);
  box-shadow: 0 8px 28px oklch(0 0 0 / 0.35), 0 0 0 1px oklch(0.55 0.20 258 / 0.12);
  transform: translateY(-1px);
}
.kpi-card.skeleton { display: flex; align-items: center; justify-content: center; min-height: 92px; }
.kpi-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--ink-2); margin-bottom: 10px;
}
.kpi-value {
  font-family: var(--font-head); font-size: 38px; font-weight: 700;
  line-height: 1; letter-spacing: -1.5px; color: var(--ink-0);
}
.kpi-value.accent { color: var(--primary-text); }
.kpi-value.green  { color: var(--green); }
.kpi-value.red    { color: var(--red); }
.kpi-value.yellow { color: var(--yellow); }
.kpi-value.muted  { color: var(--ink-1); }
.kpi-note { font-size: var(--text-xs); color: var(--ink-2); margin-top: 7px; }

/* ─── Bot Cards ──────────────────────────────────────────────── */
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--gap-md); margin-bottom: var(--gap-xl);
  max-width: 1360px; width: 100%;
}
.bot-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px;
  cursor: pointer;
  transition: border-color var(--dur-fast), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
  position: relative; overflow: hidden;
}
.bot-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--bot-color, var(--primary));
  opacity: 0.75;
  transition: opacity var(--dur-fast);
}
.bot-card:hover {
  border-color: var(--border-md);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px oklch(0 0 0 / 0.45), 0 0 0 1px oklch(0.55 0.20 258 / 0.12);
}
.bot-card:hover::before { opacity: 1; }
.bot-card-skeleton {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 40px;
  display: flex; align-items: center; justify-content: center;
}
.bot-card-head { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.bot-icon { font-size: 22px; }
.bot-name {
  font-family: var(--font-head); font-size: var(--text-md); font-weight: 700;
  line-height: 1.2;
}
.bot-desc { font-size: var(--text-xs); color: var(--ink-2); margin-top: 2px; }
.bot-stats { display: flex; gap: 18px; }
.bot-stat-val {
  font-family: var(--font-head); font-size: 17px; font-weight: 700; line-height: 1;
}
.bot-stat-lbl { font-size: 10px; color: var(--ink-2); text-transform: uppercase; margin-top: 2px; letter-spacing: 0.5px; }

/* ─── Workflow List ───────────────────────────────────────────── */
.wf-list { display: flex; flex-direction: column; gap: 4px; max-width: 1360px; width: 100%; }
.wf-item {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 11px 14px;
  display: flex; align-items: center; gap: 12px;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.wf-item:hover { background: var(--bg-2); border-color: var(--border-md); }
.wf-item-icon {
  width: 32px; height: 32px; border-radius: 7px;
  background: var(--bg-3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.wf-item-info { flex: 1; min-width: 0; }
.wf-item-name {
  font-family: var(--font-head); font-size: var(--text-sm); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wf-item-meta { font-size: var(--text-xs); color: var(--ink-2); margin-top: 2px; }
.wf-item-stats { display: flex; gap: 16px; flex-shrink: 0; }
.wf-stat-v { font-family: var(--font-head); font-size: 14px; font-weight: 700; line-height: 1; }
.wf-stat-l { font-size: 10px; color: var(--ink-2); text-transform: uppercase; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 20px;
  font-size: var(--text-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
  flex-shrink: 0; white-space: nowrap;
}
.badge-on  { background: var(--green-lo);  color: var(--green);        border: 1px solid oklch(0.63 0.16 148 / 0.25); }
.badge-off { background: var(--bg-4);       color: var(--ink-1);        border: 1px solid var(--border-md); }
.badge-err { background: var(--red-lo);    color: var(--red);           border: 1px solid oklch(0.57 0.21 25 / 0.25); }
.badge-run { background: var(--primary-lo);color: var(--primary-text);  border: 1px solid oklch(0.55 0.20 258 / 0.25); }
.badge-arc { background: var(--bg-3);      color: var(--ink-1);         border: 1px solid var(--border-md); }
.badge-warn{ background: var(--yellow-lo); color: var(--yellow);        border: 1px solid oklch(0.78 0.14 87 / 0.25); }

/* Execution status pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: var(--text-xs); font-weight: 600;
}
.pill-ok  { background: var(--green-lo);  color: var(--green);        border: 1px solid oklch(0.63 0.16 148 / 0.25); }
.pill-err { background: var(--red-lo);    color: var(--red);           border: 1px solid oklch(0.57 0.21 25 / 0.25); }
.pill-run { background: var(--primary-lo);color: var(--primary-text);  border: 1px solid oklch(0.55 0.20 258 / 0.25); }
.pill-w   { background: var(--yellow-lo); color: var(--yellow);        border: 1px solid oklch(0.78 0.14 87 / 0.25); }

/* Moderation type tags */
.type-tag {
  padding: 2px 7px; border-radius: 4px;
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.3px; flex-shrink: 0;
}
.tag-warn    { background: var(--yellow-lo);  color: var(--yellow);  }
.tag-ban     { background: var(--red-lo);     color: var(--red);     }
.tag-mute    { background: var(--primary-lo); color: var(--primary-text); }
.tag-kick    { background: var(--purple-lo);  color: var(--purple);  }
.tag-timeout { background: var(--orange-lo);  color: var(--orange);  }
.tag-unknown { background: var(--bg-4);       color: var(--ink-1);   border: 1px solid var(--border-md); }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--gap-lg);
  max-width: 1360px; width: 100%;
  /* Custom scrollbar */
  scrollbar-width: thin; scrollbar-color: var(--border-md) transparent;
}
.table-wrap::-webkit-scrollbar { height: 4px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 99px; }
table { width: 100%; min-width: 520px; border-collapse: collapse; }
thead tr {
  background: oklch(0.12 0.010 255);
  border-bottom: 1px solid var(--border-md);
}
th {
  padding: 10px 14px; text-align: left;
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--ink-2); font-weight: 700;
  white-space: nowrap; user-select: none;
}
tbody tr {
  border-bottom: 1px solid oklch(0.20 0.008 255 / 0.6);
  transition: background var(--dur-fast);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: oklch(0.15 0.010 255); box-shadow: inset 3px 0 0 var(--primary); }
td {
  padding: 11px 14px; font-size: var(--text-sm); color: var(--ink-1);
  max-width: 320px; overflow: hidden; text-overflow: ellipsis;
}
.td-hi { color: var(--ink-0); font-weight: 500; }
.td-mono { font-family: var(--font-mono); font-size: 11px; color: var(--ink-0); }
.td-loading { text-align: center; padding: 40px; max-width: none; }

.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px; border-top: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--ink-2);
}
.pagination { display: flex; gap: 4px; }
.btn-page {
  padding: 4px 11px; border: 1px solid var(--border);
  border-radius: var(--r); background: transparent;
  color: var(--ink-1); font-family: var(--font); font-size: var(--text-xs);
  cursor: pointer;
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.btn-page:hover:not(:disabled) {
  border-color: var(--primary); color: var(--primary-text);
  background: var(--primary-lo);
}
.btn-page:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 7px; margin-bottom: var(--gap-md); flex-wrap: wrap;
  max-width: 1360px; width: 100%;
}

.select-input, .text-input {
  padding: 6px 10px;
  background: var(--bg-2); border: 1px solid var(--border-md);
  border-radius: var(--r); color: var(--ink-0);
  font-family: var(--font); font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--dur-fast);
}
.select-input { cursor: pointer; }
.select-input:hover, .text-input:hover { border-color: var(--border-hi); }
.select-input:focus, .text-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-lo); }
.text-input::placeholder { color: var(--ink-2); }
.search-input { flex: 1; min-width: 180px; }

/* ─── Tabs ───────────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 2px; margin-bottom: var(--gap-md); flex-wrap: wrap; max-width: 1360px; width: 100%; }
.tab-btn {
  padding: 5px 12px; border-radius: var(--r);
  border: 1px solid transparent; background: transparent;
  color: var(--ink-2); font-family: var(--font); font-size: var(--text-sm);
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.tab-btn:hover { background: var(--bg-3); color: var(--ink-0); border-color: var(--border); }
.tab-btn.active {
  background: var(--primary-lo); color: var(--primary-text);
  border-color: oklch(0.55 0.20 258 / 0.30);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, var(--primary) 0%, oklch(0.52 0.21 252) 100%);
  border: none; border-radius: var(--r); color: #fff;
  font-family: var(--font); font-size: var(--text-sm); font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 0 oklch(1 0 0 / 0.12) inset;
  transition: filter var(--dur-fast), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base);
}
.btn-primary:hover { filter: brightness(1.12); transform: translateY(-1px); box-shadow: 0 6px 20px oklch(0.55 0.20 258 / 0.45), 0 1px 0 oklch(1 0 0 / 0.12) inset; }
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 0 oklch(1 0 0 / 0.12) inset; filter: brightness(0.95); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent; border: 1px solid var(--border-md);
  border-radius: var(--r); color: var(--ink-1);
  font-family: var(--font); font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-text); background: var(--primary-lo); }
.btn-ghost.spinning svg { animation: spin 0.8s linear infinite; }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: var(--red-lo); border: 1px solid oklch(0.57 0.21 25 / 0.25);
  border-radius: var(--r); color: var(--red);
  font-family: var(--font); font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--dur-fast);
}
.btn-danger:hover { background: var(--red-hi); }

.btn-secondary {
  flex: 1; padding: 9px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--ink-1);
  font-family: var(--font); font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.btn-secondary:hover { border-color: var(--border-md); color: var(--ink-0); background: var(--bg-4); }

.btn-save {
  flex: 2; padding: 9px;
  background: var(--primary); border: none;
  border-radius: var(--r); color: #fff;
  font-family: var(--font); font-size: var(--text-sm); font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast), box-shadow var(--dur-base);
}
.btn-save:hover { background: oklch(0.48 0.20 258); box-shadow: 0 4px 16px var(--primary-glow); }
.btn-save:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; margin-bottom: var(--gap-lg);
  background: transparent; border: 1px solid var(--border-md);
  border-radius: var(--r); color: var(--ink-1);
  font-family: var(--font); font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.btn-back:hover { border-color: var(--border-hi); color: var(--ink-0); }

.btn-link {
  background: none; border: none; color: var(--ink-2);
  font-family: var(--font); font-size: var(--text-sm);
  cursor: pointer;
  transition: color var(--dur-fast);
}
.btn-link:hover { color: var(--primary-text); }

/* Inline table action buttons */
.action-btns { display: flex; gap: 3px; }
.btn-icon {
  padding: 3px 7px; border-radius: var(--r);
  border: 1px solid var(--border); background: transparent;
  color: var(--ink-1); font-size: var(--text-xs); cursor: pointer;
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
  white-space: nowrap;
}
.btn-icon:hover { border-color: var(--border-md); color: var(--ink-0); background: var(--bg-3); }
.btn-icon.edit:hover  { border-color: var(--primary); color: var(--primary-text); background: var(--primary-lo); }
.btn-icon.done:hover  { border-color: var(--green);   color: var(--green); background: var(--green-lo); }
.btn-icon.del:hover   { border-color: var(--red);     color: var(--red); background: var(--red-lo); }

/* ─── Bot Detail ─────────────────────────────────────────────── */
.bot-detail-head {
  display: flex; align-items: center; gap: 20px;
  padding: 22px 24px; border-radius: var(--r-lg); margin-bottom: var(--gap-xl);
  border: 1px solid var(--border); background: var(--bg-1);
  position: relative; overflow: hidden;
  max-width: 1360px; width: 100%;
}
.bot-detail-head::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--bot-color, var(--primary)); opacity: 0.8;
}
.bot-detail-icon { font-size: 38px; }
.bot-detail-name {
  font-family: var(--font-head); font-size: var(--text-2xl); font-weight: 700;
  letter-spacing: -0.4px;
}
.bot-detail-desc { font-size: var(--text-sm); color: var(--ink-1); margin-top: 4px; }
.bot-detail-stats { margin-left: auto; display: flex; gap: 24px; flex-shrink: 0; }

/* ─── Info Box ───────────────────────────────────────────────── */
.info-box {
  background: linear-gradient(135deg, oklch(0.13 0.011 255) 0%, var(--bg-1) 100%);
  border: 1px solid oklch(0.55 0.20 258 / 0.22);
  border-radius: var(--r-lg); padding: 18px 20px;
  max-width: 1360px; width: 100%;
  position: relative; overflow: hidden;
  box-shadow: 0 0 0 1px oklch(0.55 0.20 258 / 0.06);
}
.info-box::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, oklch(0.70 0.18 258), oklch(0.72 0.11 295), transparent 80%);
  opacity: 0.80;
}
.info-box-title {
  font-family: var(--font-head); font-size: var(--text-sm); font-weight: 700;
  margin-bottom: 6px; color: var(--ink-0); letter-spacing: 0.1px;
}
.info-box-sub { font-size: var(--text-xs); color: var(--ink-2); margin-bottom: 12px; }
.code-block {
  display: block; padding: 10px 14px;
  background: var(--bg-0); border: 1px solid var(--border-md);
  border-radius: var(--r); font-family: var(--font-mono); font-size: 12px;
  color: var(--primary-text); word-break: break-all; margin-bottom: 10px;
  letter-spacing: 0.2px;
}
.info-box-meta { font-size: var(--text-xs); color: var(--ink-2); line-height: 2.0; overflow-wrap: break-word; word-break: break-word; }
.info-box-meta code {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-3); padding: 1px 5px; border-radius: var(--r-sm);
  border: 1px solid var(--border);
  white-space: pre-wrap; word-break: break-all;
}
.c-green  { color: var(--green); }
.c-yellow { color: var(--yellow); }
.c-red    { color: var(--red); }
.c-accent { color: var(--primary-text); }

/* ─── Loading / Empty States ─────────────────────────────────── */
.loading-state {
  display: flex; align-items: center; justify-content: center;
  padding: 50px; gap: 10px; color: var(--ink-2); font-size: var(--text-sm);
}
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 50px; gap: 8px; color: var(--ink-2); font-size: var(--text-sm);
}
.empty-icon { font-size: 26px; opacity: 0.60; }

/* ─── Modal ──────────────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: var(--z-backdrop);
  background: oklch(0.08 0.007 255 / 0.85);
  backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;           /* overlay scrolls if modal overflows */
}
#modal-overlay.show { display: flex; }

#modal {
  width: 560px;
  max-width: calc(100vw - 40px);
  max-height: calc(100dvh - 40px);   /* dvh = dynamic viewport height */
  background: linear-gradient(160deg, oklch(0.165 0.013 255) 0%, var(--bg-2) 40%);
  border: 1px solid oklch(0.55 0.20 258 / 0.25);
  border-radius: var(--r-xl); z-index: var(--z-modal);
  display: flex; flex-direction: column;
  opacity: 0;
  box-shadow: 0 40px 100px oklch(0 0 0 / 0.75), 0 0 0 1px oklch(0.55 0.20 258 / 0.12), 0 0 50px oklch(0.55 0.20 258 / 0.06);
  flex-shrink: 0; margin: auto;
}
#modal.open { animation: modal-in var(--dur-slow) var(--ease-out) forwards; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-family: var(--font-head); font-size: var(--text-lg); font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--ink-2);
  cursor: pointer; padding: 4px; border-radius: var(--r-sm);
  display: flex;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.modal-close:hover { color: var(--red); background: var(--red-lo); }

.modal-body {
  flex: 1 1 auto; min-height: 0;   /* flex scroll fix */
  overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin; scrollbar-color: var(--border-md) transparent;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 99px; }

.modal-footer {
  padding: 13px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}

/* Form elements */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: var(--text-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-2);
}
.form-label .req { color: var(--red); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg-1); border: 1px solid var(--border-md);
  border-radius: var(--r); color: var(--ink-0);
  font-family: var(--font); font-size: var(--text-sm);
  padding: 8px 11px; outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: var(--border-hi); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lo);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--ink-2); }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-hint { font-size: var(--text-xs); color: var(--ink-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.form-toggle input { accent-color: var(--primary); cursor: pointer; }

/* Toggle switch (pill / iOS style) */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: relative; display: inline-flex; align-items: center;
  width: 42px; height: 24px; background: var(--bg-4);
  border-radius: 12px; cursor: pointer; transition: background var(--dur-fast);
  flex-shrink: 0;
}
.toggle-track::after {
  content: ''; position: absolute; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink-2); transition: transform var(--dur-fast), background var(--dur-fast);
}
.toggle-input:checked + .toggle-track { background: var(--primary); }
.toggle-input:checked + .toggle-track::after { transform: translateX(18px); background: white; }
.toggle-input:focus + .toggle-track { box-shadow: 0 0 0 3px var(--primary-lo); }
.toggle-label-text { font-size: var(--text-sm); color: var(--ink-1); }

/* Color input */
input[type="color"].form-color {
  width: 42px; height: 36px; padding: 2px; border: 1px solid var(--border-md);
  border-radius: var(--r); background: var(--bg-1); cursor: pointer;
}
input[type="color"].form-color::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"].form-color::-webkit-color-swatch { border-radius: 4px; border: none; }

.form-input[readonly], .form-textarea[readonly] {
  color: var(--ink-2); background: var(--bg-0); cursor: default;
}

.panel-divider { height: 1px; background: var(--border); margin: 2px 0; }
.panel-section-title {
  font-family: var(--font-head); font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.8px;
}

/* ─── Ticket Detail / Chat ───────────────────────────────────── */
.ticket-detail-meta {
  background: var(--bg-0); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden;
  margin-bottom: 14px;
}
.tdm-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.tdm-row:last-child { border-bottom: none; }
.tdm-label {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--ink-2); white-space: nowrap;
  min-width: 90px; flex-shrink: 0;
}
.tdm-val { color: var(--ink-0); flex: 1; }

.ticket-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; padding: 0 2px;
}
.ticket-chat-header > span:first-child {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--ink-2);
}
.ticket-msg-count {
  font-size: var(--text-xs); color: var(--ink-2);
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 20px; padding: 1px 7px;
}

.ticket-chat {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-0); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px;
  min-height: 80px;
}
.ticket-chat-empty {
  text-align: center; padding: 20px;
  color: var(--ink-2); font-size: var(--text-sm); line-height: 1.7;
}

.chat-msg {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 9px 12px;
  transition: border-color var(--dur-fast);
}
.chat-msg:hover { border-color: var(--border-md); }
.chat-msg-head {
  display: flex; align-items: baseline;
  justify-content: space-between; gap: 8px; margin-bottom: 5px;
}
.chat-author {
  font-size: var(--text-xs); font-weight: 700;
  color: var(--primary-text); letter-spacing: 0.2px;
}
.chat-time {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-2); flex-shrink: 0;
}
.chat-content {
  font-size: var(--text-sm); color: var(--ink-0);
  line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.chat-attachments { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.chat-attachment-link {
  font-size: var(--text-xs); color: var(--primary-text);
  background: var(--primary-lo); border: 1px solid oklch(0.55 0.20 258 / 0.25);
  border-radius: var(--r-sm); padding: 2px 7px; text-decoration: none;
  transition: background var(--dur-fast);
}
.chat-attachment-link:hover { background: var(--primary-mid); }

/* ─── Toast ──────────────────────────────────────────────────── */
#toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.toast {
  background: var(--bg-3); border: 1px solid var(--border-md);
  border-left: 3px solid var(--border-md);
  border-radius: var(--r-md); padding: 10px 14px;
  font-size: var(--text-sm); max-width: 300px;
  box-shadow: 0 4px 20px oklch(0 0 0 / 0.4);
  animation: toast-in var(--dur-base) var(--ease-out);
  pointer-events: auto;
}
.toast.ok  {
  border-color: oklch(0.63 0.16 148 / 0.35);
  border-left-color: var(--green);
  background: oklch(0.63 0.16 148 / 0.07);
}
.toast.err {
  border-color: oklch(0.57 0.21 25 / 0.35);
  border-left-color: var(--red);
  background: oklch(0.57 0.21 25 / 0.07);
}
.toast.inf {
  border-color: oklch(0.55 0.20 258 / 0.35);
  border-left-color: var(--primary);
  background: var(--primary-lo);
}

/* ─── Confirm Dialog ─────────────────────────────────────────── */
#confirm-overlay {
  display: none;
  position: fixed; inset: 0; z-index: calc(var(--z-modal) + 10);
  background: oklch(0.08 0.007 255 / 0.88);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  padding: 20px;
}
#confirm-box {
  background: linear-gradient(160deg, oklch(0.165 0.013 255) 0%, var(--bg-2) 100%);
  border: 1px solid oklch(0.55 0.20 258 / 0.22);
  border-radius: var(--r-xl);
  padding: 24px 28px;
  width: 360px; max-width: calc(100vw - 40px);
  box-shadow: 0 30px 80px oklch(0 0 0 / 0.65), 0 0 0 1px oklch(0.55 0.20 258 / 0.10);
  animation: modal-in var(--dur-slow) var(--ease-out) both;
}
.confirm-title {
  font-family: var(--font-head); font-size: var(--text-lg); font-weight: 700;
  margin-bottom: 8px;
}
.confirm-msg {
  font-size: var(--text-sm); color: var(--ink-1); line-height: 1.55;
  margin-bottom: 20px;
}
.confirm-btns { display: flex; gap: 8px; }
.confirm-btns .btn-secondary,
.confirm-btns .btn-danger,
.confirm-btns .btn-save { flex: 1; }

/* ─── Color Swatch ───────────────────────────────────────────── */
.color-swatch {
  display: inline-block;
  width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid oklch(1 0 0 / 0.15);
  flex-shrink: 0; vertical-align: middle;
}

/* ─── Copy-ID ────────────────────────────────────────────────── */
.copy-id {
  cursor: pointer;
  padding: 1px 4px; border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
  display: inline-block;
}
.copy-id:hover {
  border-color: var(--primary);
  background: var(--primary-lo);
  color: var(--primary-text);
}

/* ─── Inline Toggle (in table cell) ─────────────────────────── */
.inline-toggle { cursor: pointer; display: inline-flex; align-items: center; }

/* ─── Auto-Refresh active ────────────────────────────────────── */
.btn-ghost.ar-on {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-lo);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid.kpi-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .kpi-grid.kpi-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .bot-detail-stats { display: none; }
  .wf-item-stats    { display: none; }
}

/* Tablet: Sidebar sichtbar, aber weniger Padding für mehr Platz */
@media (min-width: 769px) and (max-width: 1024px) {
  .main { padding-left: 20px; padding-right: 20px; }
  .page-title { font-size: 26px; }
}

@media (max-width: 768px) {
  :root { --sw: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 240px;
    box-shadow: 4px 0 24px oklch(0 0 0 / 0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sb-mobile-toggle { display: flex; }
  .main { padding: var(--gap-lg) 16px; padding-top: 60px; width: 100%; margin-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid.kpi-3 { grid-template-columns: repeat(3, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  #modal { width: calc(100vw - 24px); border-radius: var(--r-lg); }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  .bot-detail-head { flex-wrap: wrap; }
  .filter-bar { flex-wrap: wrap; }
  .page-title { font-size: 24px; }
}

@media (max-width: 540px) {
  .kpi-grid, .kpi-grid.kpi-3 { grid-template-columns: 1fr; }
  .kpi-value { font-size: 32px; }
  .kpi-grid.kpi-3 .kpi-value { font-size: 32px; }
  .filter-bar { flex-direction: column; }
  .search-input { min-width: 0; }
  .table-footer { flex-direction: column; gap: 6px; text-align: center; }
}
