/* Memory Hub - match CorianderAIGC v2 */
:root {
  --bg: #ffffff;
  --bg-s: #f7f7f8;
  --bg-sb: #ffffff;
  --tx: #1a1a1a;
  --tx2: #888;
  --bd: #f0f0f0;
  --ac: #1a1a1a;
  --ac-h: #333;
  --danger: #e53e3e;
  --r: 8px;
  --sh: 0 1px 3px rgba(0,0,0,.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--tx);
}
body { overflow: hidden; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.2); }

/* ── Shell ── */
.app-shell { display: flex; width: 100%; height: 100vh; }

/* ── Header (top) ── */
header {
  position: fixed;
  top: 0; left: 220px; right: 0;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  background: var(--bg);
  border-bottom: 1px solid var(--bd);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg-s);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--tx);
}
h1 { font-size: 20px; font-weight: 700; letter-spacing: -.3px; color: var(--tx); }
.sub { font-size: 13px; color: var(--tx2); margin-top: 2px; }
.stats-mini { font-size: 13px; color: var(--tx2); font-weight: 500; }

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  min-width: 220px;
  height: 100vh;
  background: var(--bg-sb);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--bd);
  padding: 28px 14px 16px;
  overflow-y: auto;
  position: fixed;
  left: 0; top: 0;
}
.sec { margin-bottom: 24px; }
.sec h3 {
  font-size: 16px;
  color: var(--tx);
  letter-spacing: 0;
  font-weight: 700;
  margin-bottom: 10px;
  padding: 0 8px;
  text-transform: none;
}
.filter-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.filter-list li {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 14px 0 20px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--tx2);
  font-size: 13px;
  font-weight: 400;
  transition: background .12s, color .12s;
  user-select: none;
}
.filter-list li:hover { background: var(--bg-s); color: var(--tx); }
.filter-list li.active {
  background: var(--ac);
  color: #fff;
  font-weight: 600;
}
.small {
  font-size: 13px;
  color: var(--tx2);
  padding: 0 8px;
  line-height: 1.9;
}
.small code {
  background: var(--bg-s);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--tx);
}

/* ── Content ── */
main {
  margin-left: 220px;
  padding-top: 62px;
  height: 100vh;
  overflow-y: auto;
}
.content { padding: 32px 40px; }
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
.toolbar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--bd);
  border-radius: 6px;
  font-size: 15px;
  background: var(--bg);
  color: var(--tx);
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.toolbar input:focus {
  border-color: var(--ac);
  box-shadow: 0 0 0 3px rgba(0,0,0,.04);
}

button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--bd);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg);
  color: var(--tx);
  font-family: inherit;
  white-space: nowrap;
  transition: all .15s;
}
button:hover { background: var(--bg-s); }
.btn-primary {
  background: var(--ac);
  color: #fff;
  border-color: var(--ac);
  width: 100%;
  justify-content: center;
  height: 40px;
}
.btn-primary:hover { opacity: .9; background: var(--ac); color: #fff; }
.btn-danger {
  background: var(--bg);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ── Memory cards ── */
.memory-list { display: flex; flex-direction: column; gap: 12px; }
.mem-card {
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 20px 24px;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--sh);
}
.mem-card:hover {
  border-color: var(--ac);
  box-shadow: 0 4px 12px rgba(0,0,0,.05);
}
.mem-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 16px;
}
.mem-title { font-size: 16px; font-weight: 600; color: var(--tx); letter-spacing: -.2px; }
.mem-time { font-size: 12px; color: var(--tx2); flex-shrink: 0; }
.mem-meta { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-s);
  color: var(--tx2);
  border: 1px solid var(--bd);
}
.badge.cat { background: rgba(0,0,0,.06); color: var(--tx); border-color: rgba(0,0,0,.12); }
.badge.proj { background: var(--ac); color: #fff; border-color: var(--ac); }
.badge.agent { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.mem-content {
  color: var(--tx2);
  font-size: 14px;
  line-height: 1.7;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.mem-tags { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 12px;
  color: var(--tx2);
  background: var(--bg-s);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--bd);
}

.empty {
  text-align: center;
  padding: 100px 0;
  color: var(--tx2);
  font-size: 14px;
}

/* ── Editor drawer ── */
.editor {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 600px;
  background: var(--bg);
  box-shadow: -4px 0 24px rgba(0,0,0,.08);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--bd);
}
.editor:not(.hidden) { transform: translateX(0); }
.editor-inner { display: flex; flex-direction: column; height: 100%; }
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--bd);
}
.editor-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -.2px; }
.btn-close {
  border: none;
  background: none;
  font-size: 22px;
  color: var(--tx2);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  width: auto;
  height: auto;
}
.btn-close:hover { background: var(--bg-s); color: var(--tx); }
.editor-body { flex: 1; overflow-y: auto; padding: 24px; }
.editor-body label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tx2);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.editor-body input, .editor-body select, .editor-body textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--bd);
  border-radius: 6px;
  font-size: 15px;
  margin-top: 6px;
  font-family: inherit;
  color: var(--tx);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
}
.editor-body textarea {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  min-height: 200px;
}
.editor-body input:focus, .editor-body select:focus, .editor-body textarea:focus {
  border-color: var(--ac);
  box-shadow: 0 0 0 3px rgba(0,0,0,.04);
}
.editor-foot {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--bd);
  background: var(--bg-s);
}
.editor-foot button { width: auto; padding: 8px 20px; height: auto; }
.hidden { display: none !important; }

@media (max-width: 800px) {
  .sidebar { display: none; }
  main { margin-left: 0; }
  header { left: 0; padding: 0 20px; }
  .content { padding: 20px; }
  .editor { width: 100%; }
}

/* 账号 / 管理 面板 */
.info-row { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--bd); font-size:14px; }
.info-row:last-child { border-bottom:none; }
.info-row span { color:var(--tx2); }
.info-row b { color:var(--tx); font-weight:600; }

.user-table { width:100%; border-collapse:collapse; font-size:13px; }
.user-table th { text-align:left; font-weight:600; color:var(--tx2); padding:8px 10px; border-bottom:1px solid var(--bd); font-size:12px; }
.user-table td { padding:10px; border-bottom:1px solid var(--bd); }
.user-table tr:last-child td { border-bottom:none; }
.badge-role { display:inline-block; padding:2px 8px; border-radius:6px; font-size:11px; font-weight:600; background:var(--bg-s); color:var(--tx2); }
.badge-role.admin { background:#1a1a1a; color:#fff; }
.btn-mini { padding:4px 10px; font-size:12px; border:1px solid var(--bd); background:var(--bg); border-radius:6px; cursor:pointer; margin-right:4px; }
.btn-mini:hover { border-color:var(--tx); }
.btn-mini.danger { color:#d33; border-color:#f5c6c6; }
.btn-mini.danger:hover { background:#fef2f2; }
/* ====== Dashboard ====== */
.dashboard-view { }
.dash-section { margin-bottom: 36px; }
.dash-title-row { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.dash-title { font-size: 18px; font-weight: 700; color: var(--tx); letter-spacing: -.2px; }
.dash-sub { font-size: 13px; color: var(--tx2); }

/* Agent grid */
.agent-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.agent-card {
  background: var(--bg); border: 1px solid var(--bd); border-radius: var(--r);
  padding: 18px 20px; cursor: pointer; transition: all .15s;
}
.agent-card:hover { border-color: var(--ac); box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.agent-card .a-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.agent-card .a-avatar {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.agent-card .a-avatar.xcx { background: #059669; }
.agent-card .a-avatar.xz { background: #2563eb; }
.agent-card .a-avatar.tw { background: #d97706; }
.agent-card .a-name { font-size: 15px; font-weight: 600; color: var(--tx); }
.agent-card .a-name small { font-weight: 400; font-size: 11px; color: var(--tx2); margin-left: 6px; }
.agent-card .a-stats { display: flex; gap: 16px; }
.agent-card .a-num { font-size: 22px; font-weight: 700; color: var(--tx); line-height: 1.2; }
.agent-card .a-label { font-size: 11px; color: var(--tx2); }

/* Project grid */
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.project-card {
  background: var(--bg); border: 1px solid var(--bd); border-radius: var(--r);
  padding: 14px 16px; cursor: pointer; transition: all .15s;
}
.project-card:hover { border-color: var(--ac); }
.project-card .p-bar { width: 28px; height: 3px; border-radius: 2px; margin-bottom: 10px; }
.project-card .p-bar.note { background: #8b5cf6; }
.project-card .p-bar.decision { background: #2563eb; }
.project-card .p-bar.progress { background: #059669; }
.project-card .p-bar.blocker { background: #dc2626; }
.project-card .p-bar.rule { background: #d97706; }
.project-card .p-bar.other { background: #6b7280; }
.project-card .p-name { font-size: 14px; font-weight: 600; color: var(--tx); margin-bottom: 2px; }
.project-card .p-count { font-size: 12px; color: var(--tx2); }

/* Recent activity */
.activity-list { background: var(--bg); border: 1px solid var(--bd); border-radius: var(--r); overflow: hidden; }
.activity-item {
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--bd); cursor: pointer; transition: background .12s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg-s); }
.activity-item .a-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.activity-item .a-dot.xcx { background: #059669; }
.activity-item .a-dot.xz { background: #2563eb; }
.activity-item .a-dot.tw { background: #d97706; }
.activity-item .a-text {
  flex: 1; font-size: 13px; color: var(--tx); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.activity-item .a-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 500; flex-shrink: 0;
}
.activity-item .a-tag.xcx { background: #d1fae5; color: #065f46; }
.activity-item .a-tag.xz { background: #dbeafe; color: #1e40af; }
.activity-item .a-tag.tw { background: #fef3c7; color: #92400e; }
.activity-item .a-time { font-size: 11px; color: var(--tx2); white-space: nowrap; }

.empty-dash { text-align: center; padding: 40px 0; color: var(--tx2); font-size: 13px; }

/* Version watermark */
.version-wm {
  position: fixed; bottom: 8px; right: 14px;
  font-size: 11px; color: #d1d5db; pointer-events: none; user-select: none; z-index: 999;
}

/* Nav list active state for dashboard/list */
.nav-list li.active { background: var(--ac); color: #fff; font-weight: 600; }
