/* ── Tokens ── */
:root {
  --bg: #f0f4fa;
  --panel: #ffffff;
  --panel-2: #f8fafd;
  --line: #e2e8f2;
  --text: #0f1c2e;
  --muted: #5a6a84;
  --accent: #2563eb;
  --accent-h: #1d4ed8;
  --accent-w: #eff6ff;
  --accent-l: #bfdbfe;
  --danger: #dc2626;
  --danger-bg: #fff1f1;
  --danger-l: #fecaca;
  --success-bg: #f0fdf4;
  --shadow: 0 1px 3px rgba(15,28,46,.06), 0 4px 12px rgba(15,28,46,.06);
  --sb-w: 176px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Menlo', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }

/* ── Login ── */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(140deg, #dbeafe 0%, #f0f4fa 60%);
}
.auth-card {
  width: min(400px, 100%);
  background: var(--panel);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 8px 40px rgba(15,28,46,.12);
  border: 1px solid var(--line);
}
.auth-logo { font-size: 40px; margin-bottom: 14px; }
.auth-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.err-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 20px; }

/* ── App Shell ── */
.app-shell { display: grid; grid-template-columns: var(--sb-w) 1fr; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.sb-brand {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 800; color: var(--accent);
}
.sb-brand span:first-child { font-size: 22px; }
.sb-collapse-btn {
  margin-left: auto; flex-shrink: 0;
  width: 22px; height: 22px; padding: 0;
  border-radius: 6px; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, transform .2s;
}
.sb-collapse-btn:hover { background: var(--accent-w); color: var(--accent); border-color: var(--accent-l); filter: none; }

/* ── Collapsed sidebar ── */
body.sidebar-collapsed { --sb-w: 56px; }
body.sidebar-collapsed .sb-brand { padding: 16px 8px 14px; justify-content: center; }
body.sidebar-collapsed .sb-brand-name { display: none; }
body.sidebar-collapsed .sb-collapse-btn { margin-left: 0; transform: rotate(180deg); }
body.sidebar-collapsed .sb-body { padding: 10px 6px; }
body.sidebar-collapsed .sb-section-hd { display: none; }
body.sidebar-collapsed .sb-agent-item { justify-content: center; padding: 8px 6px; }
body.sidebar-collapsed .sb-agent-item span:last-child { display: none; }
body.sidebar-collapsed .sb-empty { display: none; }
body.sidebar-collapsed .sb-foot { flex-direction: column; align-items: center; padding: 8px 6px; gap: 4px; }
body.sidebar-collapsed .sb-foot-user { flex: none; padding: 4px; justify-content: center; }
body.sidebar-collapsed .sb-user-info { display: none; }
body.sidebar-collapsed .sb-foot-actions { flex-direction: column; }
.sb-body {
  flex: 1; overflow-y: auto;
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.sb-section { margin-bottom: 8px; }
.sb-section-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--muted);
}
.sb-action-btn {
  width: 20px; height: 20px; padding: 0;
  border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted);
  font-size: 14px; font-weight: 400;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .12s, color .12s;
}
.sb-action-btn:hover { background: var(--accent-w); color: var(--accent); border-color: var(--accent-l); filter: none; }
.sb-agent-list { display: flex; flex-direction: column; gap: 1px; }
.sb-agent-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  font-size: 13px; color: var(--text);
}
.sb-agent-item:hover { background: var(--panel-2); }
.sb-agent-item.active { background: var(--accent-w); color: var(--accent); font-weight: 600; }
.sb-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: #94a3b8;
}
.sb-dot.shared { background: #22c55e; }
.sb-dot.private { background: #94a3b8; }
.sb-dot.open { background: #22c55e; }
.sb-dot.closed { background: #94a3b8; }
.sb-empty { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.sb-nav-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: background .12s;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted);
  margin-bottom: 2px;
}
.sb-nav-row:hover { background: var(--panel-2); }
.sb-nav-row.active { background: var(--accent-w); color: var(--accent); }
.sb-nav-icon { font-size: 14px; flex-shrink: 0; }
.sb-nav-text { flex: 1; }
body.sidebar-collapsed .sb-nav-text { display: none; }
body.sidebar-collapsed .sb-nav-row { justify-content: center; padding: 8px 6px; }
body.sidebar-collapsed .sb-nav-row .sb-action-btn { display: none; }

.sb-foot {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 10px 10px;
  display: flex; align-items: center; gap: 6px;
}
.sb-foot-user {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px;
  background: transparent; border: none; cursor: pointer;
  text-align: left; transition: background .12s;
}
.sb-foot-user:hover { background: var(--panel-2); filter: none; }
.sb-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-w); border: 1.5px solid var(--accent-l);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent);
}
.sb-user-info { display: flex; flex-direction: column; overflow: hidden; }
.sb-user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: 10px; color: var(--muted); }
.sb-foot-actions { display: flex; gap: 4px; }
.sb-icon-btn {
  width: 28px; height: 28px; padding: 0;
  border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .12s, color .12s;
}
.sb-icon-btn:hover { background: var(--accent-w); color: var(--accent); border-color: var(--accent-l); filter: none; }

/* ── Main Area ── */
.main { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.panel { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.panel.active { display: flex; }

/* ── Welcome ── */
.welcome-wrap {
  margin: auto; max-width: 400px;
  text-align: center; padding: 40px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.welcome-emoji { font-size: 56px; }
.welcome-wrap h2 { font-size: 22px; font-weight: 800; }
.welcome-wrap p { color: var(--muted); font-size: 14px; }

/* ── Panel Header ── */
.panel-hd {
  flex-shrink: 0;
  padding: 16px 24px 0;
  display: flex; flex-direction: column; gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.panel-hd h2 { font-size: 18px; font-weight: 800; padding-bottom: 16px; }
.panel-hd .back-btn + h2 { display: inline; }
.panel-hd > div { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; }
.panel-body { padding: 24px; overflow-y: auto; }
.back-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 0; cursor: pointer; width: auto;
}
.back-btn:hover { color: var(--accent); filter: none; }
.narrow-form { max-width: 560px; }

/* ── Agent Header ── */
.agent-hd {
  flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 24px 0;
}
.agent-hd-info {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.agent-hd-icon { display: none; }
.agent-hd-info h2 { font-size: 15px; font-weight: 700; line-height: 1.3; }
.agent-hd-desc { font-size: 12px; color: var(--muted); margin-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-hd-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* ── Tabs ── */
.tab-bar {
  display: flex; gap: 0;
  margin-top: 0;
}
.tab-btn {
  padding: 9px 16px;
  background: transparent; border: none;
  font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  width: auto;
}
.tab-btn:hover { color: var(--accent); filter: none; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Tab Panels ── */
.tab-panel { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.tab-panel.hidden { display: none; }

/* ── Chat Layout ── */
.chat-layout {
  flex: 1; overflow: hidden;
  display: grid; grid-template-columns: 180px 1fr;
}
.sessions-col {
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel-2);
}
.sessions-col-hd {
  flex-shrink: 0;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}
.session-list { flex: 1; overflow-y: auto; padding: 6px; }
.session-item {
  display: flex; align-items: center; gap: 4px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 2px;
}
.session-item-content { flex: 1; overflow: hidden; }
.session-item:hover { background: var(--line); }
.session-item.active { background: var(--accent-w); }
.session-del-btn {
  flex-shrink: 0; width: 20px; height: 20px; border: none; background: none;
  color: var(--muted); font-size: 14px; cursor: pointer; border-radius: 4px;
  display: none; align-items: center; justify-content: center; line-height: 1;
}
.session-item:hover .session-del-btn { display: flex; }
.session-del-btn:hover { background: rgba(239,68,68,.15); color: #ef4444; }
.session-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.chat-col { display: flex; flex-direction: column; overflow: hidden; }
.chat-empty-hint {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
}
.messages {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px 20px;
  scroll-behavior: smooth;
}
.msg { max-width: 80%; border-radius: 14px; padding: 11px 14px; font-size: 14px; line-height: 1.65; word-break: break-word; }
.msg-body { overflow-wrap: break-word; }
.msg-body p { margin: 0 0 8px 0; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body h1, .msg-body h2, .msg-body h3 { margin: 12px 0 6px 0; font-size: 1em; font-weight: 700; }
.msg-body h1 { font-size: 1.15em; }
.msg-body h2 { font-size: 1.05em; }
.msg-body ul, .msg-body ol { margin: 4px 0 8px 18px; padding: 0; }
.msg-body li { margin-bottom: 2px; }
.msg-body code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 3px; font-size: 0.9em; }
.msg-body pre { background: rgba(0,0,0,.06); padding: 10px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
.msg-body pre code { background: none; padding: 0; }
.msg-body blockquote { border-left: 3px solid var(--accent-l); margin: 8px 0; padding: 4px 12px; color: var(--muted); }
.msg-body strong { font-weight: 700; }
.msg-body a { color: var(--accent); text-decoration: underline; }
.msg-role { font-size: 11px; font-weight: 700; opacity: .55; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 5px; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.user .msg-role { color: rgba(255,255,255,.7); }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1.5px solid var(--line); color: var(--text); border-bottom-left-radius: 4px; }
.msg-hint { color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
.message-form {
  flex-shrink: 0;
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.message-form textarea { min-height: 52px; max-height: 150px; resize: none; flex: 1; }
.message-form button { width: auto; flex-shrink: 0; padding: 10px 20px; }

/* ── Docs Layout ── */
.docs-layout {
  flex: 1; overflow: hidden;
  display: grid; grid-template-columns: 180px 1fr;
}
.docs-tree-col {
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel-2);
}
.docs-tree-hd {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.file-list { flex: 1; overflow-y: auto; padding: 6px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: background .12s; margin-bottom: 2px;
}
.file-item:hover { background: var(--line); }
.file-item.active { background: var(--accent-w); }
.file-icon { font-size: 16px; flex-shrink: 0; }
.file-name { font-size: 12px; font-weight: 600; color: var(--text); }
.file-meta { font-size: 11px; color: var(--muted); }

.docs-editor-col { display: flex; flex-direction: column; overflow: hidden; }
.editor-toolbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.file-path-label { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.file-editor {
  flex: 1; resize: none; border: none; border-radius: 0;
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  background: #1e293b; color: #e2e8f0;
  padding: 16px;
  outline: none;
}
.file-editor:focus { box-shadow: none; border-color: transparent; }

/* ── Settings / Account ── */
.danger-zone {
  margin-top: 32px;
  padding: 16px;
  border: 1.5px solid var(--danger-l);
  border-radius: 12px;
  background: var(--danger-bg);
}
.danger-zone h4 { font-size: 13px; font-weight: 700; color: var(--danger); margin-bottom: 6px; }
.account-profile-card {
  display: flex; align-items: center; gap: 16px;
  padding: 20px;
}
.account-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-w); border: 2px solid var(--accent-l);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: var(--accent); flex-shrink: 0;
}
.account-name { font-size: 16px; font-weight: 700; }

/* ── Admin ── */
#adminPanel .panel-hd { padding-bottom: 0; }
#adminPanel .panel-hd h2 { padding-bottom: 0; margin-bottom: 8px; }

/* ── Forms / Inputs ── */
.form { display: flex; flex-direction: column; gap: 10px; }
input, select, textarea {
  width: 100%; border-radius: 9px; border: 1.5px solid var(--line);
  background: var(--panel); color: var(--text); padding: 9px 12px;
  font: inherit; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
input::placeholder, textarea::placeholder { color: #a0aec0; }
textarea { min-height: 88px; resize: vertical; }
label { font-size: 12px; font-weight: 700; color: var(--muted); }
.hint { font-weight: 400; }
.disabled-input { opacity: .5; cursor: not-allowed; }

/* ── Buttons ── */
button {
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
  border-radius: 8px; border: 1.5px solid transparent;
  padding: 9px 16px; width: 100%;
  background: var(--accent); color: #fff; border-color: var(--accent);
  transition: filter .12s, opacity .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-sm { padding: 6px 12px; font-size: 12px; width: auto; }
.ghost-btn { background: var(--panel) !important; color: var(--muted) !important; border-color: var(--line) !important; }
.ghost-btn:hover { background: var(--panel-2) !important; color: var(--text) !important; filter: none; }
.danger-btn { background: var(--danger-bg) !important; border-color: var(--danger-l) !important; color: var(--danger) !important; }
.danger-btn:hover { filter: brightness(.97); }

/* ── Cards ── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }

/* ── Lists / Items ── */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; padding: 14px; }
.item-title { font-size: 14px; font-weight: 700; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; font-size: 11px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--panel-2); }
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent-w); border: 1.5px solid var(--accent-l); color: var(--accent); }
.badge.admin { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

/* ── User Table ── */
.table-head { display: grid; grid-template-columns: 1.4fr .8fr 1fr auto; gap: 12px; padding: 8px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.user-row { display: grid; grid-template-columns: 1.4fr .8fr 1fr auto; gap: 12px; align-items: center; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.user-actions button { width: auto; font-size: 12px; padding: 5px 10px; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row-actions button { width: auto; }

/* ── Misc ── */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--danger); }
.empty-state { padding: 28px; border: 1.5px dashed #cbd5e1; border-radius: 12px; background: var(--panel-2); color: var(--muted); text-align: center; font-size: 13px; }
.helper { padding: 12px 14px; border-radius: 9px; background: var(--success-bg); border: 1px solid #86efac; color: #166534; font-size: 13px; line-height: 1.6; font-family: var(--mono); white-space: pre-wrap; word-break: break-all; }
.checkboxes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox input { width: auto; }
body:not(.user-is-admin) .admin-only { display: none; }
body.user-is-admin .member-only { display: none; }
.sb-nav-sub { padding-left: 28px; font-size: 12px; opacity: .8; }
.section-spacer { margin-top: 16px; }

/* ── Panel Header Row ── */
.panel-hd-row {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 16px;
}
.panel-hd-row h2 { padding-bottom: 0; }

/* ── Member Cards ── */
.member-card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px;
}
.member-card {
  background: var(--panel); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 16px;
  display: flex; align-items: center; gap: 12px;
}
.member-card-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-w); border: 1.5px solid var(--accent-l);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: var(--accent);
}
.member-card-info { overflow: hidden; flex: 1; }
.member-card-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-card-title { font-size: 12px; color: var(--accent); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-card-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dm-btn {
  flex-shrink: 0; width: auto; padding: 5px 12px; font-size: 12px;
  background: var(--accent-w); color: var(--accent); border: 1px solid var(--accent-l);
  border-radius: 8px; cursor: pointer; font-weight: 600;
}
.dm-btn:hover { background: var(--accent); color: #fff; filter: none; }

/* ── AI Status Indicator ── */
.ai-status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ai-status.thinking { color: var(--accent); }
.ai-status.error { color: #ef4444; }
.ai-dot-pulse { display: inline-flex; gap: 4px; }
.ai-dot-pulse::before, .ai-dot-pulse::after, .ai-dot-pulse { content: ''; }
.ai-dot-pulse, .ai-dot-pulse::before, .ai-dot-pulse::after {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: aiPulse 1.2s ease-in-out infinite;
}
.ai-dot-pulse::before { animation-delay: -0.3s; }
.ai-dot-pulse::after { animation-delay: 0.3s; }
.ai-dot-pulse { position: relative; }
.ai-dot-pulse::before, .ai-dot-pulse::after { content: ''; position: absolute; top: 0; }
.ai-dot-pulse::before { left: -10px; }
.ai-dot-pulse::after { left: 10px; }
@keyframes aiPulse {
  0%, 80%, 100% { opacity: .3; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Password Reset Modal ── */
.pwd-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.pwd-modal { background: var(--panel); border-radius: 14px; padding: 24px; width: 360px; max-width: 90vw; box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.pwd-modal h3 { margin: 0 0 16px; font-size: 16px; }
.pwd-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pwd-label { font-size: 13px; color: var(--muted); width: 50px; flex-shrink: 0; }
.pwd-value { font-size: 14px; font-weight: 600; }
.pwd-input { flex: 1; border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: monospace; font-size: 14px; font-weight: 600; background: var(--panel-2); cursor: text; outline: none; }
.pwd-input:focus { border-color: var(--accent); }
.pwd-copy-btn { flex-shrink: 0; padding: 6px 14px; font-size: 12px; background: var(--accent); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; min-width: 52px; }
.pwd-copy-btn:hover { filter: brightness(1.1); }
.pwd-close-btn { background: var(--panel-2); color: var(--text); border: 1.5px solid var(--line); }
.pwd-close-btn:hover { background: var(--line); }

/* ── Agent List Panel ── */
.list-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted);
  margin-bottom: 12px;
}
.agent-card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px;
}
.agent-card {
  background: var(--panel); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 16px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.agent-card:hover { border-color: var(--accent-l); box-shadow: var(--shadow); }
.agent-card-name { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.agent-card-desc { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.agent-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.agent-card-tags { display: flex; gap: 6px; }
.ai-tag { background: #ede9fe; border-color: #c4b5fd; color: #6d28d9; }

/* ── Task Board Panel ── */
.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--panel);
  border: 1.5px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer; transition: border-color .15s;
}
.task-row:hover { border-color: var(--accent-l); }
.task-row-main { flex: 1; }
.task-row-title { font-size: 14px; font-weight: 600; }
.task-row-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tag-open { background: var(--success-bg); border-color: #86efac; color: #166534; }

/* ── Task Panel ── */
.task-hd {
  flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 24px 0;
}
.task-hd-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.task-hd-info h2 { font-size: 15px; font-weight: 700; }
.badge.closed-badge { background: #f1f5f9; border-color: #cbd5e1; color: var(--muted); }
.task-meta-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 4px; padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.task-tab-panel { flex: 1; }
.task-tab-panel.hidden { display: none; }
#taskDetailForm textarea:disabled,
#taskDetailForm input:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; flex-direction: row; flex-wrap: wrap; }
  .chat-layout, .docs-layout { grid-template-columns: 1fr; }
  .sessions-col, .docs-tree-col { border-right: none; border-bottom: 1px solid var(--line); max-height: 200px; }
  .table-head, .user-row { grid-template-columns: 1fr; }
  .user-actions { justify-content: flex-start; }
}
