:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --line: #e7e9f0;
  --line-soft: #f0f2f7;
  --text: #1b2030;
  --text-2: #4c5468;
  --muted: #8a91a6;
  --brand: #4f46e5;
  --brand-soft: #eef0ff;
  --brand-2: #6366f1;
  --success: #16a34a;
  --success-soft: #e9f8ef;
  --warn: #d97706;
  --warn-soft: #fdf4e3;
  --danger: #dc2626;
  --danger-soft: #fdeeee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 26, 45, .04), 0 8px 24px rgba(20, 26, 45, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------ 登录 */
.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 9vw;
  background:
    radial-gradient(900px 520px at 18% 22%, rgba(99, 102, 241, .32), transparent 62%),
    radial-gradient(700px 480px at 78% 78%, rgba(56, 189, 248, .22), transparent 60%),
    linear-gradient(120deg, #0e1226 0%, #1a2148 52%, #222a5c 100%);
  overflow: hidden;
}
.login::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(720px 520px at 30% 50%, #000 20%, transparent 78%);
}
.login-card {
  position: relative;
  width: 396px;
  padding: 34px 32px 26px;
  background: rgba(255, 255, 255, .97);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(6, 10, 30, .45);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.logo {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}
.login-title { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.login-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.login-form label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--text-2); }
.login-form input {
  width: 100%;
  margin-top: 7px;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfd;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.login-form input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); background: #fff; }
.login-form .btn { margin-top: 6px; height: 44px; }
.login-error { min-height: 18px; margin-top: 10px; font-size: 12px; color: var(--danger); }
.login-tip { margin-top: 14px; font-size: 11px; color: var(--muted); text-align: center; }

/* ------------------------------------------------------------ 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; }
.brand-name { font-size: 15px; font-weight: 700; }
.brand-sub { font-size: 10px; color: var(--muted); letter-spacing: .6px; margin-top: 2px; }
#nav { padding: 6px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 10px; margin-bottom: 3px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 13.5px;
  transition: background .16s, color .16s;
}
.nav-item:hover { background: var(--line-soft); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-icon {
  width: 18px; height: 18px; flex: 0 0 18px; display: block; opacity: .78;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 1px 0 5px 0; }
.nav-sub-item {
  display: flex; align-items: center;
  height: 31px; padding: 0 10px 0 38px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  transition: background .16s, color .16s;
}
.nav-sub-item:hover { background: var(--line-soft); color: var(--text); }
.nav-sub-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-foot {
  display: flex; align-items: center; gap: 9px;
  margin: 12px; padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfbfe;
}
.exec-dot { width: 8px; height: 8px; border-radius: 50%; background: #c7ccdb; flex: 0 0 8px; }
.exec-dot.online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); }
.exec-dot.offline { background: #f59e0b; }
.exec-text { font-size: 11.5px; line-height: 1.4; min-width: 0; }
.exec-text > div:first-child { font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exec-text .muted { font-size: 10.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 56px; padding: 0 30px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.appbar-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.appbar-brand { font-size: 13px; font-weight: 600; color: var(--text-2); }
.appbar-sep { font-size: 12px; color: #c3c7d4; }
.appbar-page { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head { padding: 22px 30px 14px; }
.page-head h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.page-sub { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 11px 0 5px;
  border: 1px solid var(--line); border-radius: 20px;
  background: #fff; cursor: pointer;
}
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.dropdown {
  position: absolute; right: 0; top: 42px; z-index: 40;
  min-width: 132px; padding: 5px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow);
}
.dropdown button, .dropdown .dropdown-item {
  display: block; width: 100%; height: 34px; padding: 0 10px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--text-2); font-size: 13px; text-align: left;
  text-decoration: none; line-height: 34px; cursor: pointer;
}
.dropdown button:hover, .dropdown .dropdown-item:hover { background: var(--line-soft); }
.dropdown .dropdown-item.hidden { display: none; }

.view { padding: 0 30px 34px; flex: 1; }

/* ------------------------------------------------------------ 通用组件 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text-2);
  font-size: 13px; cursor: pointer;
  transition: background .16s, border-color .16s, color .16s, box-shadow .16s;
}
.btn:hover { border-color: #d2d6e3; background: #fcfcff; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #443cd6; border-color: #443cd6; }
.btn.primary:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--danger); border-color: #f4d3d3; background: #fffafa; }
.btn.block { width: 100%; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; }
.card-body { padding: 18px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.badge.gray { background: #f1f3f8; color: var(--text-2); }
.badge.blue { background: var(--brand-soft); color: var(--brand); }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------ KPI */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { margin-top: 8px; font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.kpi-value small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi-foot { margin-top: 6px; font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------ 任务列表 */
.task-list { display: flex; flex-direction: column; }
.task-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 190px 120px 130px;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .15s;
}
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: #fafbff; }
.task-thumb {
  width: 62px;
  aspect-ratio: 9 / 16;
  height: auto;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef0ff, #e3e7ff);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand); font-size: 16px;
  object-fit: cover;
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.task-title { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.task-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.task-step { font-size: 12px; color: var(--text-2); }
.progress { margin-top: 7px; height: 5px; border-radius: 6px; background: #eef0f6; overflow: hidden; }
.progress > span {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  transition: width .4s ease;
}
.task-actions { display: flex; gap: 8px; justify-content: flex-end; }

.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 8px; }

/* ------------------------------------------------------------ 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.input, select.input, textarea.input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfd;
  outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 11px; line-height: 1.6; resize: vertical; }
.input:focus, select.input:focus, textarea.input:focus {
  border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(99, 102, 241, .1); background: #fff;
}
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row .name { font-size: 13px; font-weight: 600; }
.switch-row .desc { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 42px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 20px; background: #d8dbe8;
  cursor: pointer; transition: background .18s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .18s;
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 18px;
  background: #fff; font-size: 12.5px; cursor: pointer;
  transition: all .16s;
}
.chip input { display: none; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.dropzone {
  border: 1.5px dashed #ccd2e4;
  border-radius: var(--radius);
  background: #fbfcff;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .16s, background .16s;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: #f7f8ff; }
.dropzone .dz-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.dropzone .dz-sub { font-size: 12px; color: var(--muted); }
.file-chip {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.file-chip .fc-name { font-size: 13px; font-weight: 600; }
.file-chip .fc-meta { font-size: 11.5px; color: var(--muted); }
.file-chip .fc-bar { margin-top: 6px; height: 4px; border-radius: 4px; background: #eef0f6; overflow: hidden; }
.file-chip .fc-bar > span { display: block; height: 100%; background: var(--brand); transition: width .2s; }

/* ------------------------------------------------------------ 任务详情 */
.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.detail-title { display: flex; align-items: center; gap: 10px; }
.detail-title input {
  border: 1px solid transparent; background: transparent;
  font-size: 19px; font-weight: 700; padding: 4px 8px; border-radius: 8px;
  max-width: 520px;
}
.detail-title input:hover { border-color: var(--line); }
.detail-title input:focus { border-color: var(--brand-2); outline: none; background: #fff; }
.detail-sub { margin-top: 7px; font-size: 12px; color: var(--muted); display: flex; gap: 14px; }

.steps { display: flex; gap: 6px; padding: 14px 18px; overflow-x: auto; }
.step {
  flex: 1 1 0; min-width: 92px;
  padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fbfbfd;
  text-align: left;
}
.step .st-idx { font-size: 10.5px; color: var(--muted); }
.step .st-name { font-size: 12px; font-weight: 600; margin-top: 4px; white-space: nowrap; }
.step.done { background: var(--success-soft); border-color: #cdebd8; }
.step.done .st-name { color: #14803f; }
.step.active { background: var(--brand-soft); border-color: #cdd2ff; box-shadow: 0 0 0 3px rgba(99, 102, 241, .09); }
.step.active .st-name { color: var(--brand); }
.step .st-bar { margin-top: 7px; height: 3px; border-radius: 3px; background: rgba(0,0,0,.06); overflow: hidden; }
.step .st-bar > span { display: block; height: 100%; background: var(--brand); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr); gap: 16px; align-items: start; }
.preview-wrap { background: #0f1220; border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 320px; }
.preview-wrap video { width: 100%; max-height: 520px; display: block; }
.preview-empty { color: #7b83a3; font-size: 13px; padding: 60px 20px; text-align: center; }

.artifact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.artifact {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .16s, background .16s;
}
.artifact:hover { border-color: #c9cfe4; background: #fafbff; }
.artifact .ai {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 30px;
  background: #f2f4fa; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.artifact .an { font-size: 12.5px; font-weight: 600; }
.artifact .am { font-size: 11px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.table th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.table input {
  width: 100%; height: 30px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 7px; background: #fbfbfd;
  outline: none;
}
.table input:hover { border-color: var(--line); }
.table input:focus { border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 3px rgba(99,102,241,.08); }

/* 账号管理 */
.users-tabs { display: inline-flex; gap: 4px; margin-bottom: 16px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.users-tab { padding: 7px 16px; border-radius: 7px; font-size: 13px; color: var(--text-2); text-decoration: none; }
.users-tab:hover { color: var(--text); }
.users-tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.user-new-card { max-width: 720px; }
.users-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.user-form-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.user-role-list { display: flex; flex-direction: column; gap: 12px; }
.user-role-card { padding: 12px; border: 1px solid var(--line-soft); border-radius: 9px; background: #fbfbfe; }
.user-role-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.user-role-head strong { font-size: 13px; }
.user-role-perms { display: flex; flex-wrap: wrap; gap: 5px; }
.user-role-perms span { padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line); background: #fff; font-size: 10.5px; color: var(--muted); }
.users-table-wrap { overflow-x: auto; }
.user-self { margin-left: 6px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table select.input { height: 30px; min-width: 84px; padding: 0 6px; font-size: 12px; }
@media (max-width: 1100px) { .users-grid { grid-template-columns: 1fr; } }
.cap-table-wrap { max-height: 420px; overflow: auto; }

.tabs { display: flex; gap: 6px; padding: 4px; background: #f2f4fa; border-radius: 9px; width: fit-content; }
.tab {
  height: 28px; padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; font-size: 12.5px; color: var(--text-2); cursor: pointer;
}
.tab.on { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 3px rgba(20,26,45,.09); }

.alert {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 11px 13px; border-radius: 10px; font-size: 12.5px; line-height: 1.6;
}
.alert.warn { background: var(--warn-soft); color: #8a5a12; }
.alert.error { background: var(--danger-soft); color: #a02020; }
.alert.info { background: var(--brand-soft); color: #3b36b8; }
.alert.success { background: var(--success-soft); color: #146c37; }

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 14px);
  padding: 10px 18px; border-radius: 10px;
  background: rgba(23, 27, 44, .94); color: #fff;
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.split-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 12.5px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text-2); word-break: break-all; }

@media (max-width: 1180px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
