/* AI Company Computer — 中文化驾驶舱样式 (V1 polish)
 * 设计目标：
 *  · 一致的深色工作台外观，所有页面共享同一侧栏 + 主区域布局。
 *  · 显式 CJK 字体栈，避免中文回退到衬线字体。
 *  · 所有现有 class（tasks-list、tasks-table、tasks-filter、tasks-detail、
 *    timeline、knowledge-*、tasks-shell 等）都获得统一外观，
 *    不再依赖浏览器裸控件样式。
 */

:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1f2530;
  --surface-3: #262d3a;
  --border: #2a3140;
  --border-strong: #3a4356;
  --text: #e6edf3;
  --muted: #8b949e;
  --muted-2: #adb5bd;
  --accent: #4d8eff;
  --accent-strong: #69a1ff;
  --accent-soft: rgba(77, 142, 255, 0.18);
  --success: #3fb950;
  --warning: #d29922;
  --danger: #ff6b6b;
  --info: #58a6ff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 4px 24px rgba(0, 0, 0, 0.35);
  font-family:
    -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "微软雅黑", "Noto Sans CJK SC", "Source Han Sans SC",
    "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }
body.aico {
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; }

.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.error { color: var(--danger); margin-top: 0.75rem; }

h1, h2, h3, h4 { color: var(--text); font-weight: 600; }
h1 { font-size: 1.45rem; margin: 0 0 0.4rem 0; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.6rem 0; }
h3 { font-size: 0.98rem; margin: 1.1rem 0 0.4rem 0; }

code, pre, kbd, samp, .mono {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
    "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.85em;
}
code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text);
}

pre.md-source, pre.codeblock {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.55;
}

/* ---------- 登录 ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 0%, rgba(77, 142, 255, 0.08), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(77, 142, 255, 0.05), transparent 50%),
    var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.1rem 1.85rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.3rem; margin: 0 0 0.35rem 0; }
.auth-card .auth-lead { color: var(--muted); margin: 0; font-size: 0.92rem; }
.auth-card form { display: grid; gap: 0.55rem; margin-top: 1.25rem; }
.auth-card label {
  font-size: 0.85rem;
  color: var(--muted);
  display: grid;
  gap: 0.35rem;
}
.auth-card input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  font: inherit;
  width: 100%;
}
.auth-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.auth-card button {
  margin-top: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.auth-card button:hover { background: var(--accent-strong); }

/* ---------- 通用驾驶舱外壳 ---------- */
.cockpit {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.5rem;
}
.brand-sub {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.78rem;
  display: block;
  margin-top: 0.15rem;
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.18rem;
}
.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 0.93rem;
}
.nav-item a:hover {
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
}
.nav-item.is-active a {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.nav-item .nav-emoji {
  width: 1.25rem;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.9;
}

.who {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.who-name { font-weight: 600; }
.who-role { font-size: 0.75rem; color: var(--muted); }
.link-button {
  margin-top: 0.55rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted-2);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}
.link-button:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.cockpit-main {
  padding: 1.75rem 2.1rem 3rem 2.1rem;
  max-width: 1400px;
  width: 100%;
}
.cockpit-header h1 { margin: 0 0 0.25rem 0; }
.cockpit-header .lead {
  color: var(--muted);
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
}

/* 顶栏（移动端折叠） */
@media (max-width: 900px) {
  .cockpit { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    flex-direction: column;
  }
  .cockpit-main { padding: 1.25rem 1rem 2.5rem 1rem; }
}

/* ---------- 卡片 ---------- */
.cards {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 0.98rem; margin: 0 0 0.5rem 0; }
.card .card-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  margin: 0.15rem 0 0.4rem 0;
}
.card .card-foot { color: var(--muted); font-size: 0.85rem; }

/* ---------- 兼容老的 tasks-shell（已被统一外壳取代，但保留布局 fallback） ---------- */
.tasks-shell { display: contents; }
.tasks-shell__header,
.tasks-shell__nav,
.tasks-shell__brand,
.tasks-shell__who { display: none !important; }
.tasks-shell__main { display: block; }

/* ---------- 列表区头部 ---------- */
.tasks-list__header,
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.tasks-list__header h1,
.section-header h1 { margin: 0; }
.tasks-list__header p,
.section-header p { margin: 0.25rem 0 0 0; color: var(--muted); }

/* ---------- 按钮 ---------- */
.button,
.tasks-list__header a.button,
button[type="submit"],
form button:not(.link-button):not([type="button"]),
.tasks-detail__controls button,
.tasks-filter button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.button:hover,
button[type="submit"]:hover,
form button:not(.link-button):not([type="button"]):hover {
  background: var(--accent-strong);
  color: #fff;
  text-decoration: none;
}
.button--secondary,
a.button--secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.button--secondary:hover { background: var(--surface-3); color: var(--text); }
.button--danger { background: var(--danger); }
.button--danger:hover { background: #ff8a8a; }

/* ---------- 表单 / 过滤栏 ---------- */
.tasks-filter,
.filter-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.9rem 0 1.25rem 0;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tasks-filter label,
.filter-row label,
.tasks-form label,
.tasks-detail__controls label,
.knowledge-upload label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 0;
}
.tasks-filter label > span.muted,
.tasks-form label > span.muted { font-size: 0.78rem; }

input[type="text"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.9rem;
  min-width: 0;
  width: 100%;
}
.tasks-filter input,
.tasks-filter select,
.filter-row input,
.filter-row select { min-width: 12rem; }
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
textarea {
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
}

input[type="file"] {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  font-size: 0.85rem;
}
input[type="file"]::file-selector-button {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.7rem;
  margin-right: 0.6rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
input[type="file"]::file-selector-button:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

/* 任务新建页 form 布局 */
.tasks-form form {
  display: grid;
  gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem;
  margin-top: 1rem;
}
.tasks-form .form-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ---------- 表格 ---------- */
.tasks-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0.5rem 0 1.5rem 0;
  font-size: 0.9rem;
}
.tasks-table thead th {
  text-align: left;
  background: var(--surface-2);
  color: var(--muted-2);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: 0.01em;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.tasks-table tbody td,
.tasks-table tbody th {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tasks-table tbody th {
  background: var(--surface-2);
  color: var(--muted-2);
  font-weight: 500;
  text-align: left;
  width: 28%;
}
.tasks-table tbody tr:last-child td,
.tasks-table tbody tr:last-child th { border-bottom: 0; }
.tasks-table tbody tr:hover td { background: rgba(77, 142, 255, 0.04); }
.tasks-table code { background: transparent; border: 0; padding: 0; }

/* ---------- 状态徽章 ---------- */
.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-3);
  color: var(--muted-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status--pending,
.status--draft { background: rgba(210, 153, 34, 0.15); color: #e0b14a; border-color: rgba(210, 153, 34, 0.35); }
.status--in_progress,
.status--awaiting_review { background: rgba(88, 166, 255, 0.15); color: #79b8ff; border-color: rgba(88, 166, 255, 0.35); }
.status--completed,
.status--approved,
.status--promoted,
.status--active { background: rgba(63, 185, 80, 0.15); color: #5bd57b; border-color: rgba(63, 185, 80, 0.35); }
.status--cancelled,
.status--rejected,
.status--retired { background: rgba(255, 107, 107, 0.15); color: #ff8a8a; border-color: rgba(255, 107, 107, 0.35); }
.status--revisions_requested,
.status--revise,
.status--paused { background: rgba(177, 117, 252, 0.15); color: #c8a4ff; border-color: rgba(177, 117, 252, 0.4); }

/* ---------- 任务详情 / 通用详情 ---------- */
.tasks-detail {
  display: grid;
  gap: 1.2rem;
}
.tasks-detail__breadcrumb { margin-bottom: 0.3rem; }
.tasks-detail__breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted-2);
  font-size: 0.9rem;
}
.tasks-detail__breadcrumb a:hover { color: var(--accent-strong); text-decoration: none; }

.tasks-detail header h1 { margin-bottom: 0.4rem; }
.tasks-detail header p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.tasks-detail header p .status { margin-right: 0.4rem; }

.tasks-detail__body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.tasks-detail__body h2 { margin-top: 0; }

.tasks-detail__controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.tasks-detail__controls h2 { margin-top: 0; }
.tasks-detail__controls form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.6rem;
}
.tasks-detail__controls .tasks-filter { margin: 0.6rem 0 0 0; }

/* ---------- 事件时间线 ---------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.timeline__item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
}
.timeline__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  align-items: center;
}
.timeline__meta time { color: var(--muted); }
.timeline__summary { font-size: 0.92rem; color: var(--text); }
.timeline__summary code { font-size: 0.82em; }

/* ---------- 知识库专属 ---------- */
.knowledge-upload,
.knowledge-search,
.knowledge-docs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
}
.knowledge-upload h2,
.knowledge-search h2,
.knowledge-docs h2 { margin-top: 0; }
.knowledge-upload .tasks-filter,
.knowledge-search .tasks-filter { margin: 0.6rem 0 0 0; }

/* ---------- 智能体页面 ---------- */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  display: grid;
  gap: 0.55rem;
  box-shadow: var(--shadow);
}
.agent-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}
.agent-card__name {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
}
.agent-card__slug {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.agent-card__role {
  color: var(--muted-2);
  font-size: 0.88rem;
}
.agent-card__meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.7rem;
  margin-top: 0.4rem;
  font-size: 0.84rem;
}
.agent-card__meta dt { color: var(--muted); }
.agent-card__meta dd { margin: 0; color: var(--text); word-break: break-all; }
.agent-card__meta dd code { font-size: 0.82em; }

/* ---------- 通用提示 / 空状态 ---------- */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 1.5rem;
  text-align: center;
  margin: 1rem 0;
}

.callout {
  background: rgba(77, 142, 255, 0.08);
  border-left: 3px solid var(--accent);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  margin: 0.7rem 0;
  font-size: 0.9rem;
}
.callout--warn {
  background: rgba(210, 153, 34, 0.1);
  border-left-color: var(--warning);
}
.callout--danger {
  background: rgba(255, 107, 107, 0.1);
  border-left-color: var(--danger);
}

/* hr 分隔 */
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* 兼容标签 strong / em */
strong { color: var(--text); }
em { color: var(--muted-2); }

/* 演示环境横幅 —— 仅在 VERCEL/AICO_DEMO_BANNER 触发时渲染。 */
.demo-banner {
  background: rgba(210, 153, 34, 0.18);
  color: var(--text);
  border-bottom: 1px solid var(--warning);
  padding: 0.55rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* 子任务列表 + 老板操作区的轻量样式 */
.children-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6rem 0;
}
.children-table th,
.children-table td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border-strong);
  font-size: 0.9rem;
}
.children-table th { color: var(--muted); font-weight: 600; }
.tasks-filter--stacked {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.tasks-detail__blocked .callout strong { margin-right: 0.3rem; }

/* 侧栏“我的待办”入口 + 徽章。 */
.my-todos {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.4rem 0.75rem 0.75rem 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}
.my-todos:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}
.my-todos__icon { font-size: 1rem; }
.my-todos__label { flex: 1; }
.my-todos__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  padding: 0 0.4rem;
  height: 1.35rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
}
.my-todos__badge--zero {
  background: var(--surface-3);
  color: var(--muted);
}
.my-todos--has { border-color: var(--danger); }

/* 任务列表“只看我的”/“查看全部”切换条。 */
.tasks-list__toolbar {
  display: flex;
  gap: 0.5rem;
  margin: 0.2rem 0 0.6rem 0;
}

/* 委派表单里的“立即调度”复选项：让 checkbox 与文字同行展示。 */
.tasks-filter__check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.25rem 0;
}
.tasks-filter__check input[type="checkbox"] { margin: 0; }

/* ----------------------------------------------------------------------
   反馈 5.22-4 改动：
   1. 智能体运行状态卡片（agent-run）—— 任务详情页显示运行中/完成/失败。
   2. 父子任务在任务池里的层级标识与父任务面包屑。
   ---------------------------------------------------------------------- */

.agent-run {
  margin: 0.5rem 0 1rem 0;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.agent-run h2 {
  margin-top: 0;
  font-size: 1rem;
}
.agent-run__badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.agent-run__badge--running   { background: rgba(70, 130, 220, 0.18); border-color: #4682dc; }
.agent-run__badge--completed { background: rgba(60, 160, 100, 0.18); border-color: #3ca064; }
.agent-run__badge--failed,
.agent-run__badge--timeout   { background: rgba(210, 70, 70, 0.18); border-color: var(--danger); }

/* 任务池父子层级 */
.task-row--child td:nth-child(2) { padding-left: 1.4rem; }
.task-row__indent { color: var(--muted); margin-right: 0.25rem; }
.task-row__parent {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.task-row__parent a { color: var(--muted); }

.tasks-detail__breadcrumb a + a { margin-left: 0.5rem; }

/* 登录页：演示环境提示卡片 */
.auth-demo-note {
  margin: 0.8rem 0 1rem 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--warning);
  background: rgba(210, 153, 34, 0.12);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.5;
  border-radius: var(--radius-sm);
}
