/* ═══════════════════════════════════════════════════════
   Spector Dashboard v4 — Modern Flat Dark
   No gradients. Solid colors. Sharp edges. Rich animations.
   Hot-Reload Memory, Sandbox Test Chat with Persona Masks,
   Operator RBAC Permissions, 0 Emojis, SVG Icons Only.
   ═══════════════════════════════════════════════════════ */

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

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

:root {
  /* Colors */
  --bg:       #0d0d0d;
  --bg1:      #111111;
  --bg2:      #161616;
  --bg3:      #1c1c1c;
  --bg4:      #242424;
  --border:   #262626;
  --border2:  #333333;
  --border3:  #444444;
  --text:     #f0f0f0;
  --text2:    #999999;
  --text3:    #555555;

  /* Solid accent palette — no gradients */
  --accent:   #7c6cf8;
  --accent-h: #6857ea;
  --teal:     #22d3ee;
  --green:    #22c55e;
  --red:      #ef4444;
  --orange:   #f97316;
  --yellow:   #eab308;
  --pink:     #ec4899;

  /* Layout */
  --sw: 240px;
  --r:  10px;
  --rs: 6px;

  /* Animation speeds */
  --t-fast:   120ms;
  --t-normal: 220ms;
  --t-slow:   380ms;
}

html { scroll-behavior: smooth; height: 100%; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ══════════════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════════════ */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
  position: relative;
}

.login-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  animation: card-in 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 52px; height: 52px;
  background: var(--accent);
  color: #fff;
  font-size: 24px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  margin-bottom: 16px;
  animation: logo-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

.login-title {
  font-size: 26px; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text); margin-bottom: 5px;
}
.login-subtitle {
  font-size: 13.5px; color: var(--text3);
}

.login-alert {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--rs);
  padding: 11px 14px;
  font-size: 12.5px; color: var(--red);
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
  animation: shake 0.35s ease;
}
.login-alert.hidden { display: none !important; }
.alert-ico { display: flex; align-items: center; flex-shrink: 0; }
.alert-ico svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-ico {
  position: absolute; left: 14px;
  color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.input-ico svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2; fill: none; }

.input-text {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 12px 14px;
  color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input-text:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.input-text.with-icon { padding-left: 42px; }
.input-text.with-eye  { padding-right: 42px; }

.input-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 10px 12px;
  color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; transition: border-color var(--t-fast);
  resize: vertical;
}
.input-textarea:focus { border-color: var(--accent); }

.btn-pwd-eye {
  position: absolute; right: 10px;
  background: transparent; border: none;
  color: var(--text3); padding: 6px;
  border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--t-fast);
  z-index: 2;
}
.btn-pwd-eye:hover { color: var(--text); }
.btn-pwd-eye svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8; fill: none; }

.btn-login {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--rs);
  padding: 13px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all var(--t-fast);
  margin-top: 6px;
  width: 100%;
}
.btn-login:hover { background: var(--accent-h); transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-login-ico svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2.2; fill: none; }

.login-footer {
  text-align: center;
  font-size: 11.5px; color: var(--text3);
  margin-top: 24px; padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.app-layout.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sw);
  min-height: 100vh;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-top { padding: 18px 14px 0; }
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  color: #fff;
  font-size: 16px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--rs);
  flex-shrink: 0;
}
@keyframes logo-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.logo-name {
  display: block;
  font-size: 14px; font-weight: 700; color: var(--text);
  letter-spacing: -0.3px;
}
.logo-handle {
  display: block;
  font-size: 11px; color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
}

/* User Badge in Sidebar */
.user-badge-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  padding: 8px 10px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ub-avatar {
  width: 26px; height: 26px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 50%;
  font-size: 11px; font-weight: 700;
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.ub-info { flex: 1; min-width: 0; }
.ub-name {
  display: block;
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ub-role {
  display: block;
  font-size: 10px; color: var(--text3); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 600;
}
.ub-logout-btn {
  background: transparent; border: none;
  color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 4px; border-radius: 4px;
  transition: all var(--t-fast);
}
.ub-logout-btn:hover { color: var(--red); background: rgba(239,68,68,0.1); }
.ub-logout-btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }

/* Bot Control Widget */
.bot-widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px;
  margin-bottom: 14px;
}
.bot-widget-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.bot-widget-row:last-child { margin-bottom: 0; }
.widget-label { font-size: 10.5px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  transition: all var(--t-normal);
}
.status-pill.running {
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.3);
  color: var(--green);
}
.status-pill.stopped {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.2);
  color: var(--red);
}

.status-dot-sm {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text3);
  transition: background var(--t-normal);
  flex-shrink: 0;
}
.status-dot-sm.running {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34,197,94,0.4);
  animation: ping 1.5s infinite;
}
.status-dot-sm.stopped { background: var(--red); }

@keyframes ping {
  0%  { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100%{ box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.autostart-pill {
  font-size: 10.5px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text3);
  transition: all var(--t-normal);
}
.autostart-pill.on {
  background: rgba(124,108,248,0.1);
  border-color: rgba(124,108,248,0.3);
  color: var(--accent);
}

.bot-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.ctrl-btn {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 5px 3px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.ctrl-btn:hover { border-color: var(--border2); color: var(--text); transform: translateY(-1px); }
.ctrl-btn:active { transform: translateY(0); }
.ctrl-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.ctrl-start:hover  { border-color: var(--green); color: var(--green); }
.ctrl-stop:hover   { border-color: var(--red);   color: var(--red);   }
.ctrl-restart:hover{ border-color: var(--yellow); color: var(--yellow); }
.ctrl-auto:hover   { border-color: var(--accent); color: var(--accent); }

.ctrl-btn.loading { animation: btn-pulse 0.8s ease infinite; }
@keyframes btn-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.btn-mini-ico { display: flex; align-items: center; justify-content: center; }
.btn-mini-ico svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 0 8px;
  display: flex; flex-direction: column; gap: 2px;
}

.nav-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: none; border-radius: var(--r);
  background: transparent; color: var(--text2);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  text-align: left; position: relative;
}
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active {
  background: var(--bg3);
  color: var(--accent);
  border: 1px solid var(--border);
}
.nav-btn.active .nav-ico { color: var(--accent); }

.nav-ico {
  width: 18px; text-align: center; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-ico svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.nav-lbl { flex: 1; }
.nav-count {
  font-size: 10px; font-weight: 700;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text3); padding: 1px 6px;
  border-radius: 10px; min-width: 20px; text-align: center;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
}
.refresh-all {
  width: 100%; padding: 7px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--rs); color: var(--text2);
  font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.refresh-all:hover { border-color: var(--border2); color: var(--text); }
.refresh-all svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2; fill: none; }

/* ══════════════════════════════════════════════════════
   MAIN
   ══════════════════════════════════════════════════════ */
.main {
  margin-left: var(--sw);
  flex: 1; min-height: 100vh;
  padding: 28px 32px;
  max-width: calc(1200px + var(--sw));
}

.page { display: none; }
.page.active { display: block; animation: page-in 0.3s ease; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.ph {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.ph-title { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.ph-sub   { font-size: 13px; color: var(--text3); flex: 1; }
.ph-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ══════════════════════════════════════════════════════
   STATS GRID
   ══════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  position: relative; overflow: hidden;
  cursor: default;
  transition: border-color var(--t-fast), transform var(--t-normal);
  animation: card-in 0.4s ease both;
}
.stat-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--c, var(--accent));
}
.stat-ico {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--rs);
  background: var(--bg3);
  color: var(--c, var(--accent));
  margin-bottom: 10px;
}
.stat-ico svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.stat-val {
  font-size: 24px; font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1; letter-spacing: -1px;
  color: var(--text);
}
.stat-lbl {
  font-size: 10.5px; color: var(--text3);
  margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}

/* ══════════════════════════════════════════════════════
   SPLIT ROW (overview bottom)
   ══════════════════════════════════════════════════════ */
.split-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.panel {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  animation: card-in 0.4s 0.2s ease both;
}
.panel-hd {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  color: var(--text2);
}
.panel-hd svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.panel-ico { display: flex; align-items: center; }
.panel-bd { padding: 14px 16px; }

/* Evolution overview */
.evo-mood-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 6px 12px; border-radius: var(--rs);
  font-size: 12px; font-weight: 500; color: var(--text);
  margin-bottom: 10px;
}
.evo-mini-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.evo-mini-list li {
  font-size: 11px; color: var(--text2);
  padding: 5px 9px;
  background: var(--bg3); border-radius: var(--rs);
  border-left: 2px solid var(--accent);
  line-height: 1.4;
}
.evo-mini-list li.joke { border-left-color: var(--pink); }

.log-mini {
  max-height: 230px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0;
}
.lm-line {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  line-height: 1.6;
  padding: 1px 0;
  color: var(--text3);
  white-space: pre-wrap;
  word-break: break-all;
  border-bottom: 1px solid transparent;
  animation: fade-in-line 0.2s ease both;
}
.lm-line:hover { background: var(--bg3); }
.lm-line.INFO    { color: var(--teal); }
.lm-line.WARNING { color: var(--yellow); }
.lm-line.ERROR   { color: var(--red); }

@keyframes fade-in-line {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: none; }
}

/* ══════════════════════════════════════════════════════
   SANDBOX / TEST CHAT WITH PERSONA MASKS
   ══════════════════════════════════════════════════════ */
.sandbox-header-card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  animation: card-in 0.35s ease both;
}

.sb-mask-select-wrap { min-width: 240px; flex: 1; }
.sb-mask-preview {
  flex: 2; min-width: 260px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 8px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.sb-mp-item { font-size: 11.5px; display: flex; gap: 6px; }
.sb-mp-lbl { color: var(--text3); font-weight: 600; text-transform: uppercase; font-size: 9.5px; }
.sb-mp-val { color: var(--text); }

.sb-mask-opts {
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}

.sandbox-debug-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 14px; overflow: hidden;
  animation: card-in 0.25s ease both;
}
.sandbox-debug-card.hidden { display: none !important; }

.sandbox-chat-card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex; flex-direction: column;
  height: calc(100vh - 280px); min-height: 440px;
  overflow: hidden; animation: card-in 0.4s ease both;
}

.sandbox-messages {
  flex: 1; overflow-y: auto;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 12px;
}

.sb-msg {
  max-width: 76%; padding: 10px 14px;
  border-radius: var(--r); font-size: 13px; line-height: 1.55;
  animation: msg-in 0.2s ease both;
  position: relative; display: flex; flex-direction: column; gap: 4px;
}
.sb-msg.user {
  align-self: flex-end;
  background: var(--bg3);
  border: 1px solid rgba(124,108,248,0.25);
  border-bottom-right-radius: 4px;
}
.sb-msg.model {
  align-self: flex-start;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.sb-msg-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text3); margin-bottom: 2px;
}
.sb-msg-mask-tag {
  background: var(--bg4); color: var(--accent);
  padding: 1px 6px; border-radius: 3px; font-size: 9.5px;
}
.sb-msg-reaction {
  display: inline-flex; align-items: center; gap: 4px;
  align-self: flex-start; margin-top: 4px;
  font-size: 11px; padding: 2px 7px; border-radius: 12px;
  background: var(--bg3); border: 1px solid var(--border);
}
.sb-msg-media {
  margin-top: 6px; padding: 6px 10px;
  background: var(--bg3); border: 1px solid rgba(34,211,238,0.3);
  border-radius: var(--rs); font-size: 11.5px; color: var(--teal);
  display: inline-flex; align-items: center; gap: 6px;
}

.sb-media-card {
  margin-top: 8px;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px;
  width: 190px;
  align-self: flex-start;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: card-in 0.25s ease both;
}
.sb-media-frame {
  width: 100%; height: 160px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3);
  border-radius: var(--rs);
  overflow: hidden; position: relative;
}
.sb-media-content {
  width: 100%; height: 100%; object-fit: contain;
  transition: transform var(--t-fast);
}
.sb-media-content:hover { transform: scale(1.05); }
.sb-media-loading {
  font-size: 11px; color: var(--text3);
}
.sb-media-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0 2px;
}
.sb-media-id {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.sb-media-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  background: rgba(34,211,238,0.12); color: var(--teal);
  padding: 1px 5px; border-radius: 3px; border: 1px solid rgba(34,211,238,0.25);
  flex-shrink: 0;
}

.sb-typing {
  align-self: flex-start;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 16px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text3); font-size: 12px;
  animation: card-in 0.2s ease;
}
.sb-typing-dot {
  width: 6px; height: 6px; background: var(--accent);
  border-radius: 50%; animation: type-bounce 1.2s infinite ease-in-out;
}
.sb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.sb-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes type-bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1.1); opacity: 1; } }

.sb-suggestions {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  display: flex; align-items: center; gap: 6px; overflow-x: auto;
}
.sb-sug-lbl { font-size: 10.5px; color: var(--text3); font-weight: 600; text-transform: uppercase; white-space: nowrap; }
.sug-pill {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 4px 10px; border-radius: 14px;
  font-size: 11.5px; cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast);
}
.sug-pill:hover { border-color: var(--accent); color: var(--text); }

.sb-composer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg1);
  display: flex; gap: 8px; align-items: center;
}
.sb-input { flex: 1; }
.btn-sb-send {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--rs);
  padding: 12px 20px; font-size: 13px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--t-fast); flex-shrink: 0;
}
.btn-sb-send:hover { background: var(--accent-h); transform: translateY(-1px); }
.btn-sb-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ══════════════════════════════════════════════════════
   CHATS & SHORT-TERM MEMORY INSPECTOR
   ══════════════════════════════════════════════════════ */
.chat-list { display: flex; flex-direction: column; gap: 8px; }

.chat-item {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-normal), background var(--t-fast);
  animation: card-in 0.3s ease both;
}
.chat-item:hover {
  border-color: var(--border2);
  background: var(--bg2);
  transform: translateX(4px);
}
.chat-ico {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: var(--r);
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
}
.chat-ico svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.chat-ico.private { border-color: rgba(124,108,248,0.3); color: var(--accent); }
.chat-ico.group   { border-color: rgba(34,211,238,0.3);  color: var(--teal);   }

.chat-info { flex: 1; min-width: 0; }
.chat-name { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.chat-prev { font-size: 12px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-prev.bot { color: var(--text2); }

.chat-right { text-align: right; flex-shrink: 0; }
.chat-count { font-size: 18px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.type-badge {
  display: inline-block; margin-top: 3px;
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px;
}
.tbp { background: rgba(124,108,248,0.1); color: var(--accent); border: 1px solid rgba(124,108,248,0.2); }
.tbg { background: rgba(34,211,238,0.1);  color: var(--teal);   border: 1px solid rgba(34,211,238,0.2); }
.tblock { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }

/* Chat Detail View */
.chat-detail { display: flex; flex-direction: column; height: calc(100vh - 120px); }
.chat-detail.hidden { display: none; }
.chat-detail-hd {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.back-btn {
  padding: 7px 12px; border: 1px solid var(--border);
  border-radius: var(--rs); background: var(--bg2);
  color: var(--text2); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }
.cd-name { font-size: 16px; font-weight: 700; }
.cd-meta { font-size: 12px; color: var(--text3); margin-top: 1px; }

.cd-actions { display: flex; align-items: center; gap: 8px; }
.btn-clear-stm {
  padding: 7px 12px; border: 1px solid var(--border);
  border-radius: var(--rs); background: var(--bg2);
  color: var(--text3); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-clear-stm:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,0.08); }

.btn-chat-block {
  padding: 7px 14px; border: 1px solid var(--border);
  border-radius: var(--rs); background: var(--bg2);
  color: var(--red); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-chat-block:hover { border-color: var(--red); background: rgba(239,68,68,0.08); }
.btn-chat-block.blocked { color: var(--green); border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.08); }
.btn-chat-block.blocked:hover { border-color: var(--green); background: rgba(34,197,94,0.15); }

/* Interactive Messages with 1-click Delete */
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.msg {
  max-width: 72%; padding: 10px 14px;
  border-radius: var(--r); font-size: 13px; line-height: 1.55;
  animation: msg-in 0.2s ease both;
  position: relative;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.msg.user {
  align-self: flex-end;
  background: var(--bg3);
  border: 1px solid rgba(124,108,248,0.25);
  border-bottom-right-radius: 4px;
}
.msg.model {
  align-self: flex-start;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text2);
}
.msg-top-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 5px;
}
.msg-author-time {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.msg-who { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.6; }
.msg-time-badge {
  font-size: 10px; color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg1); padding: 1px 6px; border-radius: 3px;
  border: 1px solid var(--border);
}
.msg-time-badge svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 2; fill: none; }
.btn-msg-del {
  background: transparent; border: none;
  color: var(--text3); cursor: pointer;
  padding: 2px 4px; border-radius: 3px;
  opacity: 0; transition: opacity var(--t-fast), color var(--t-fast);
}
.msg:hover .btn-msg-del { opacity: 1; }
.btn-msg-del:hover { color: var(--red); }
.btn-msg-del svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }

/* ══════════════════════════════════════════════════════
   LONG-TERM MEMORY (LTM / FACTS) EDITOR
   ══════════════════════════════════════════════════════ */
.facts-cat-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-pill {
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text2); padding: 5px 11px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
}
.cat-pill:hover { border-color: var(--border2); color: var(--text); }
.cat-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

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

.fact-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  animation: card-in 0.35s ease both;
  transition: border-color var(--t-fast), transform var(--t-normal);
  display: flex; flex-direction: column;
}
.fact-card:hover { border-color: var(--border2); transform: translateY(-2px); }

.fact-card-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.fact-who { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 7px; color: var(--text); }
.fact-who svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; color: var(--text3); }

.fact-card-actions { display: flex; align-items: center; gap: 6px; }
.btn-add-fact-sm {
  background: rgba(124,108,248,0.12); border: 1px solid rgba(124,108,248,0.3);
  color: var(--accent); padding: 3px 8px; border-radius: var(--rs);
  font-size: 10.5px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-add-fact-sm:hover { background: var(--accent); color: #fff; }

.btn-clear-facts-sm {
  background: transparent; border: 1px solid var(--border);
  color: var(--text3); padding: 3px 6px; border-radius: var(--rs);
  font-size: 10.5px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-clear-facts-sm:hover { color: var(--red); border-color: var(--red); }

.fact-list { list-style: none; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.fact-item {
  font-size: 12px; color: var(--text2);
  padding: 8px 10px;
  background: var(--bg3); border-radius: var(--rs);
  border-left: 3px solid var(--teal);
  line-height: 1.45;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  animation: card-in 0.25s ease both;
  transition: border-color var(--t-fast);
}
.fact-item:hover { border-left-color: var(--accent); }
.fact-item.cat-dates     { border-left-color: var(--orange); }
.fact-item.cat-likes     { border-left-color: var(--pink);   }
.fact-item.cat-relations { border-left-color: var(--yellow); }

.fact-text-wrap { flex: 1; }
.fact-cat-tag {
  display: inline-block; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 1px 5px; border-radius: 3px; margin-bottom: 3px;
  background: var(--bg4); color: var(--text3);
}

.fact-item-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; opacity: 0.3; transition: opacity var(--t-fast); }
.fact-item:hover .fact-item-actions { opacity: 1; }
.btn-fact-act {
  background: transparent; border: none; color: var(--text3);
  padding: 3px; border-radius: 3px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-fact-act:hover { color: var(--text); }
.btn-fact-act.del:hover { color: var(--red); }
.btn-fact-act svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }

/* ══════════════════════════════════════════════════════
   USER PROFILES (LTM Profiles & Schemas)
   ══════════════════════════════════════════════════════ */
.btn-create-prof {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--rs);
  padding: 7px 14px; font-size: 12px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--t-fast);
}
.btn-create-prof:hover { background: var(--accent-h); transform: translateY(-1px); }

.profiles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.profile-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  animation: card-in 0.35s ease both;
  transition: border-color var(--t-fast), transform var(--t-normal);
  display: flex; flex-direction: column;
}
.profile-card:hover { border-color: var(--border2); transform: translateY(-2px); }

.profile-card-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.profile-main-info { display: flex; align-items: center; gap: 10px; }
.profile-av {
  width: 36px; height: 36px; border-radius: var(--rs);
  background: var(--bg3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); flex-shrink: 0;
}
.profile-av svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.profile-nm   { font-size: 14px; font-weight: 700; }
.profile-hndl { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }

.prof-actions { display: flex; align-items: center; gap: 4px; }
.btn-prof-act {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 5px 8px; border-radius: var(--rs);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-prof-act:hover { border-color: var(--accent); color: var(--accent); }
.btn-prof-act.del:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,0.08); }
.btn-prof-act svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }

.profile-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.pfield { font-size: 12px; }
.pfield-lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); margin-bottom: 3px; }
.pfield-val { color: var(--text2); line-height: 1.45; }
.pfield-rel {
  display: inline-block; background: rgba(249,115,22,0.1);
  color: var(--orange); border: 1px solid rgba(249,115,22,0.2);
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500;
}

/* ══════════════════════════════════════════════════════
   CHARACTER STATE & EXISTENTIAL CRISIS CONTROLLER
   ══════════════════════════════════════════════════════ */
.btn-reset-state {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25);
  color: var(--red); padding: 7px 12px; border-radius: var(--rs);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-reset-state:hover { background: var(--red); color: #fff; }

.char-state-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  margin-bottom: 20px; animation: card-in 0.35s ease both;
}
.state-form-grid { display: flex; flex-direction: column; gap: 16px; }

.crisis-header-row { display: flex; align-items: center; justify-content: space-between; }
.crisis-badge {
  font-size: 12px; font-weight: 700; font-family: 'JetBrains Mono', monospace;
  padding: 3px 9px; border-radius: 12px;
  background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.3);
  transition: all var(--t-fast);
}
.crisis-badge.med  { background: rgba(234,179,8,0.12);  color: var(--yellow); border-color: rgba(234,179,8,0.3); }
.crisis-badge.high { background: rgba(239,68,68,0.15);  color: var(--red);    border-color: rgba(239,68,68,0.35); }

.slider-wrap { width: 100%; }
.crisis-range {
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--bg3); outline: none; -webkit-appearance: none; appearance: none;
  cursor: pointer; margin: 8px 0;
}
.crisis-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; cursor: pointer;
  box-shadow: 0 0 8px rgba(124,108,248,0.6);
  transition: transform var(--t-fast);
}
.crisis-range::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider-ticks {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--text3); font-weight: 600;
}

.mood-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.preset-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 4px 9px; border-radius: 4px;
  font-size: 11px; font-weight: 500; cursor: pointer;
  transition: all var(--t-fast);
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-save-state {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--rs);
  padding: 9px 18px; font-size: 13px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--t-fast);
}
.btn-save-state:hover { background: var(--accent-h); transform: translateY(-1px); }

/* Evolution Items Grid with 1-click Delete & Add */
#evo-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.evo-card { background: var(--bg1); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; animation: card-in 0.4s ease both; display: flex; flex-direction: column; }
.evo-card-hd {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text2);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg2);
}
.evo-card-hd svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; color: var(--text3); }
.evo-card-bd { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }

.evo-items { display: flex; flex-direction: column; gap: 6px; }
.evo-item {
  font-size: 12px; color: var(--text2); line-height: 1.45;
  padding: 7px 10px; background: var(--bg3);
  border-radius: var(--rs); border-left: 3px solid var(--accent);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  animation: card-in 0.3s ease both;
}
.evo-item.joke { border-left-color: var(--pink); }
.evo-item:hover .btn-evo-del { opacity: 1; }

.btn-evo-del {
  background: transparent; border: none; color: var(--text3);
  padding: 2px 4px; border-radius: 3px; cursor: pointer;
  opacity: 0.2; transition: all var(--t-fast);
}
.btn-evo-del:hover { color: var(--red); opacity: 1; }
.btn-evo-del svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }

.evo-add-row { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.evo-add-input {
  flex: 1; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 7px 10px;
  color: var(--text); font-size: 12px; outline: none;
}
.evo-add-input:focus { border-color: var(--accent); }
.btn-evo-add {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: 7px 12px; border-radius: var(--rs);
  font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast); white-space: nowrap;
}
.btn-evo-add:hover { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════════════════════
   MEDIA
   ══════════════════════════════════════════════════════ */
.media-pills { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.mpill {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 10px 18px; text-align: center;
  min-width: 100px;
}
.mpill-val { font-size: 22px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.mpill-lbl { font-size: 11px; color: var(--text3); margin-top: 2px; }

.table-wrap { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 14px; text-align: left;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text3); background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0; border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text2); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }

.media-row { cursor: pointer; transition: background var(--t-fast); }
.media-row:hover .media-row-inner { background: var(--bg2); }
.media-row-inner { display: flex; align-items: center; }
.media-row-inner td { padding: 10px 14px; }

.media-preview-row { display: none; background: var(--bg2); }
.media-preview-row.open { display: table-row; animation: slide-open 0.25s ease; }
@keyframes slide-open { from { opacity: 0; } to { opacity: 1; } }
.media-preview-cell { padding: 16px !important; }
.preview-inner { display: flex; align-items: flex-start; gap: 16px; }
.preview-media {
  width: 120px; height: 120px; flex-shrink: 0;
  border-radius: var(--r); border: 1px solid var(--border);
  background: var(--bg3); display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.preview-media img, .preview-media video { width: 100%; height: 100%; object-fit: contain; }
.preview-media .pm-loading { font-size: 11px; color: var(--text3); text-align: center; }
.preview-info { flex: 1; }
.preview-id   { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent); margin-bottom: 8px; }
.preview-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.ptag { font-size: 11px; padding: 2px 8px; background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; color: var(--text3); }
.p-status { margin-bottom: 8px; }

.mid { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--accent); }
.filled { color: var(--green); font-weight: 600; }
.empty  { color: var(--red);   font-weight: 600; }
.ttype  { font-size: 11px; }

/* ══════════════════════════════════════════════════════
   BLOCKED SECTION & FORMS
   ══════════════════════════════════════════════════════ */
.block-form-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  animation: card-in 0.35s ease both; margin-bottom: 20px;
}
.block-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: span 2; }
.form-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.sel-full {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 10px 12px;
  color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; cursor: pointer; transition: border-color var(--t-fast);
}
.sel-full:focus { border-color: var(--accent); }
.form-actions { grid-column: span 2; display: flex; justify-content: flex-end; margin-top: 4px; }
.btn-block-submit {
  background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3);
  color: var(--red); padding: 9px 18px; border-radius: var(--rs);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast); display: inline-flex; align-items: center; gap: 6px;
}
.btn-block-submit:hover { background: var(--red); color: #fff; border-color: var(--red); transform: translateY(-1px); }

.btn-unblock {
  background: transparent; border: 1px solid var(--border);
  color: var(--text2); padding: 4px 10px; border-radius: var(--rs);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-unblock:hover { border-color: var(--green); color: var(--green); background: rgba(34,197,94,0.08); }

/* ══════════════════════════════════════════════════════
   USERS MANAGEMENT RBAC STYLES
   ══════════════════════════════════════════════════════ */
.user-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.role-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.role-pill {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rs); color: var(--text2);
  font-size: 11.5px; font-weight: 600; padding: 6px 12px;
  cursor: pointer; transition: all var(--t-fast);
}
.role-pill:hover { border-color: var(--accent); color: var(--text); background: var(--bg3); }

.perms-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rs); padding: 12px;
}
.perm-chk {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text2); cursor: pointer; user-select: none;
}
.perm-chk input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.perm-chk:hover { color: var(--text); }

.btn-user-submit {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--rs);
  padding: 9px 18px; font-size: 13px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--t-fast);
}
.btn-user-submit:hover { background: var(--accent-h); transform: translateY(-1px); }

.perm-tags-wrap { display: flex; flex-wrap: wrap; gap: 4px; }
.perm-tag {
  font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 4px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text3);
}
.perm-tag.all   { background: rgba(124,108,248,0.15); color: var(--accent); border-color: rgba(124,108,248,0.3); }
.perm-tag.admin { background: rgba(249,115,22,0.15);  color: var(--orange); border-color: rgba(249,115,22,0.3); }

.role-badge {
  display: inline-block; font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
}
.role-badge.admin { background: rgba(124,108,248,0.12); color: var(--accent); border-color: rgba(124,108,248,0.3); }
.role-badge.master { background: rgba(249,115,22,0.12); color: var(--orange); border-color: rgba(249,115,22,0.3); }

.master-badge {
  font-size: 10px; font-weight: 700;
  background: rgba(249,115,22,0.15); color: var(--orange);
  border: 1px solid rgba(249,115,22,0.3);
  padding: 1px 5px; border-radius: 3px; margin-left: 6px;
}

.btn-del-user {
  background: transparent; border: 1px solid var(--border);
  color: var(--text3); padding: 4px 8px; border-radius: var(--rs);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-del-user:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,0.08); }

.btn-pwd-user {
  background: transparent; border: 1px solid var(--border);
  color: var(--text2); padding: 4px 8px; border-radius: var(--rs);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast); margin-right: 4px;
}
.btn-pwd-user:hover { border-color: var(--accent); color: var(--accent); }

.btn-perm-user {
  background: transparent; border: 1px solid var(--border);
  color: var(--text2); padding: 4px 8px; border-radius: var(--rs);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast); margin-right: 4px;
}
.btn-perm-user:hover { border-color: var(--teal); color: var(--teal); }

/* ══════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade-in 0.2s ease;
}
.modal-backdrop.hidden { display: none !important; }

.modal-card {
  width: 100%; max-width: 440px;
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  overflow: hidden; animation: card-in 0.25s ease both;
}
.modal-card.wide { max-width: 580px; }

.modal-hd {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg2);
}
.modal-title { font-size: 14px; font-weight: 700; color: var(--text); }
.modal-close {
  background: transparent; border: none; color: var(--text3);
  font-size: 16px; cursor: pointer; padding: 3px 6px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--text); }
.modal-bd { padding: 18px; }
.modal-desc { font-size: 12px; color: var(--text3); margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.prof-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-save-prof {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--rs);
  padding: 8px 16px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all var(--t-fast);
}
.btn-save-prof:hover { background: var(--accent-h); }

/* ══════════════════════════════════════════════════════
   LOG PAGE
   ══════════════════════════════════════════════════════ */
.log-box {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px;
  height: calc(100vh - 160px); overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
}
.log-line {
  display: block; font-size: 11.5px; line-height: 1.65;
  padding: 1px 0; color: var(--text3);
  white-space: pre-wrap; word-break: break-all;
  animation: fade-in-line 0.15s ease both; border-radius: 3px;
}
.log-line:hover { background: var(--bg2); padding-left: 4px; }
.log-line.INFO    { color: var(--teal);   }
.log-line.WARNING { color: var(--yellow); }
.log-line.ERROR   { color: var(--red);    }

/* ══════════════════════════════════════════════════════
   MISC UI
   ══════════════════════════════════════════════════════ */
.sel {
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); padding: 6px 10px; border-radius: var(--rs);
  font-size: 12px; cursor: pointer; outline: none;
}
.sel:focus { border-color: var(--accent); }
.btn-sm {
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text2); padding: 6px 12px; border-radius: var(--rs);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

/* Skeleton */
.skel {
  background: var(--bg2); animation: skel-pulse 1.4s ease infinite;
  border-radius: var(--rs); height: 18px;
}
@keyframes skel-pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

/* Empty state */
.empty-st { text-align: center; padding: 52px 24px; color: var(--text3); font-size: 13px; }
.empty-st svg { width: 40px; height: 40px; stroke: currentColor; stroke-width: 1.2; fill: none; margin-bottom: 12px; color: var(--border2); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 18px;
  font-size: 13px; font-weight: 500; z-index: 99999;
  animation: toast-in 0.3s ease; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.ok  { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red);   }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Sidebar Backdrop Overlay */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Top Navigation Bar (Hidden on desktop) */
.mobile-top-bar {
  display: none;
}
.btn-sidebar-close {
  display: none;
}

/* Mobile Menu Lock */
body.menu-locked {
  overflow: hidden;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 960px) {
  :root { --sw: 0px; }

  .app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 54px;
    box-sizing: border-box;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 85vw);
    background: var(--bg1);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    box-shadow: 8px 0 32px rgba(0,0,0,0.8);
    display: flex !important;
    overflow-y: auto;
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  .btn-sidebar-close {
    display: flex;
    align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--rs);
    color: var(--text2);
    margin-left: auto;
    cursor: pointer;
    transition: all var(--t-fast);
    flex-shrink: 0;
  }
  .btn-sidebar-close:hover {
    color: #fff;
    background: var(--bg4);
  }

  .mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
    padding: 0 16px;
    margin: 0;
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 500;
    box-sizing: border-box;
  }

  .btn-mobile-menu {
    width: 38px; height: 38px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--rs);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text);
    transition: background var(--t-fast), border-color var(--t-fast);
  }
  .btn-mobile-menu:hover {
    background: var(--bg3);
    border-color: var(--border2);
  }
  .btn-mobile-menu svg {
    width: 20px; height: 20px;
    stroke: currentColor; fill: none; stroke-width: 2;
  }

  .mobile-brand {
    display: flex; align-items: center; gap: 9px;
  }
  .mobile-brand-icon {
    width: 28px; height: 28px;
    background: var(--accent);
    color: #fff;
    font-size: 13px; font-weight: 800;
    border-radius: var(--rs);
    display: flex; align-items: center; justify-content: center;
  }
  .mobile-brand-text {
    display: flex; flex-direction: column;
  }
  .mobile-brand-title {
    font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.2;
  }
  .mobile-brand-section {
    font-size: 11px; color: var(--text3); line-height: 1.2;
  }

  .mobile-actions {
    display: flex; align-items: center; gap: 10px;
  }
  .mobile-status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text3);
    transition: background var(--t-fast), box-shadow var(--t-fast);
  }
  .mobile-status-dot.online {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
  }
  .mobile-status-dot.offline {
    background: var(--red);
  }
  .btn-mobile-refresh {
    width: 36px; height: 36px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--rs);
    display: flex; align-items: center; justify-content: center;
    color: var(--text2);
    cursor: pointer;
    transition: all var(--t-fast);
  }
  .btn-mobile-refresh:hover {
    color: #fff;
    background: var(--bg3);
  }

  .main {
    margin-left: 0;
    padding: 16px 14px 36px 14px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .logo-text, .nav-lbl, .nav-count, .bot-widget, .ub-info, .sidebar-footer span {
    display: block !important;
  }
  .nav-btn {
    justify-content: flex-start !important;
    padding: 10px 12px !important;
  }

  .ph {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .ph-controls {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }
  .split-row, #evo-layout, .user-form-grid, .perms-grid, .prof-modal-grid, .sandbox-header-card {
    grid-template-columns: 1fr;
  }
  .form-group.full-width {
    grid-column: span 1;
  }

  .facts-cat-pills {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }
  .cat-pill {
    flex-shrink: 0;
  }

  .sb-suggestions {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 6px;
  }
  .sug-pill {
    flex-shrink: 0;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--rs);
  }

  .modal-box {
    width: calc(100vw - 24px) !important;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 18px 14px;
    margin: 12px auto;
  }

  .cd-actions {
    flex-wrap: wrap;
  }

  .login-card {
    width: calc(100vw - 32px);
    max-width: 440px;
    padding: 24px 18px;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .facts-grid, .profiles-grid, .block-form-grid {
    grid-template-columns: 1fr;
  }
  .sb-msg {
    max-width: 90%;
  }
  .sb-media-card {
    width: 160px;
  }
  .sb-media-frame {
    height: 130px;
  }
  .chat-detail-hd {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* ══════════════════════════════════════════════════════
   AI SETTINGS & DIAGNOSTICS
   ══════════════════════════════════════════════════════ */
.ai-diag-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-diag-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}

.ai-status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text3);
  display: inline-block;
  transition: all var(--t-normal);
}

.ai-status-indicator.ready {
  background: var(--teal);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.4);
}

.ai-status-indicator.testing {
  background: var(--yellow);
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
  animation: pulse-dot 1s infinite alternate;
}

.ai-status-indicator.ok {
  background: var(--green);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.6);
}

.ai-status-indicator.err {
  background: var(--red);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

@keyframes pulse-dot {
  from { opacity: 0.4; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

.ai-status-text {
  color: var(--text);
  flex: 1;
}

.ai-latency-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--teal);
}

.ai-diag-details {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  font-size: 12px;
  color: var(--text2);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.5;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.ai-diag-details.ok {
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.ai-diag-details.err {
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.token-limit-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  white-space: nowrap;
}

.model-tag-active {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(124, 108, 248, 0.2);
  border: 1px solid var(--accent);
  color: var(--accent);
  margin-left: 6px;
}

.btn-select-model {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  transition: all var(--t-fast);
}

.btn-select-model:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-select-model.active {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--green);
  color: var(--green);
  cursor: default;
}

/* AI Provider Switcher */
.ai-provider-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-prov-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  text-align: left;
  transition: all var(--t-fast);
  position: relative;
}

.ai-prov-tab:hover {
  border-color: var(--border2);
  background: var(--bg2);
  transform: translateY(-1px);
}

.ai-prov-tab.active {
  border-color: var(--accent);
  background: rgba(124, 108, 248, 0.08);
  box-shadow: 0 0 20px rgba(124, 108, 248, 0.15);
}

.ai-prov-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--rs);
  background: var(--bg3);
  color: var(--accent);
}

.ai-prov-tab.active .ai-prov-icon {
  background: var(--accent);
  color: #fff;
}

.btn-activate-prov {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: var(--rs);
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  cursor: pointer;
  transition: all var(--t-fast);
}

.btn-activate-prov:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.btn-activate-prov.active-current {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--green);
  cursor: default;
}


.ai-prov-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-prov-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.ai-prov-sub {
  font-size: 11px;
  color: var(--text2);
}

.ai-prov-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: var(--green);
}

.ai-prov-badge.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .ai-provider-switcher {
    grid-template-columns: 1fr;
  }
}

/* ======================================================================
   GEMINI MULTI-KEY POOL STYLES
   ====================================================================== */

.key-pool-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
  margin-top: 10px;
}

.key-pool-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.key-pool-title-group {
  flex: 1;
  min-width: 250px;
}

.key-pool-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-pool-desc {
  font-size: 11.5px;
  color: var(--text2);
  margin: 0;
  line-height: 1.45;
}

.key-pool-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
}

.stat-pill.stat-total {
  border-color: var(--border2);
  color: var(--text);
}

.stat-pill.stat-active {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--green);
}

.stat-pill.stat-limited {
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(234, 179, 8, 0.3);
  color: #eab308;
}

.stat-pill.stat-invalid {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.key-pool-autocheck-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  padding: 10px 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.autocheck-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.autocheck-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.autocheck-lbl {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

.autocheck-select {
  padding: 5px 10px;
  font-size: 12px;
  width: auto;
  min-width: 170px;
  background: var(--bg2);
}

.autocheck-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text2);
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.autocheck-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text2);
  display: inline-block;
}

.autocheck-dot.active {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: autocheck-pulse 2s infinite;
}

@keyframes autocheck-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.key-pool-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--bg);
  margin-top: 12px;
}

.key-pool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.key-pool-table th {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.key-pool-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.key-pool-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.key-num-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg3);
  color: var(--text2);
  display: inline-block;
}

.key-num-badge.primary-badge {
  background: rgba(124, 108, 248, 0.2);
  border: 1px solid rgba(124, 108, 248, 0.4);
  color: var(--accent);
}

.key-code-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.key-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
}

.key-status-badge.status-active {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
}

.key-status-badge.status-rate_limited {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #eab308;
}

.key-status-badge.status-invalid {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.key-status-badge.status-untested {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
}

.latency-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text2);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.latency-pill.latency-fast {
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.3);
}

.latency-pill.latency-med {
  color: #eab308;
  border-color: rgba(234, 179, 8, 0.3);
}

.latency-pill.latency-slow {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.btn-icon-action {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--rs);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
}

.btn-icon-action:hover {
  background: var(--bg2);
  border-color: var(--border2);
  color: var(--text);
  transform: translateY(-1px);
}

.btn-icon-action.btn-del:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--red);
}

.btn-icon-action.btn-set-primary:hover {
  background: rgba(124, 108, 248, 0.15);
  border-color: rgba(124, 108, 248, 0.4);
  color: var(--accent);
}

