:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6eaf2;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef2ff;
  --green: #16a34a;
  --green-soft: #ecfdf5;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --sidebar: #0b1220;
  --sidebar-2: #111a2e;
  --sidebar-ink: #cbd5e1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; }

/* Login */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 520px at 12% 0%, rgba(99, 102, 241, .35), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(124, 58, 237, .25), transparent 55%),
    #0b1220;
}
.login-card {
  width: 100%; max-width: 430px; background: rgba(255,255,255,.97);
  border: 1px solid rgba(255,255,255,.5); border-radius: 24px;
  padding: 34px 32px 30px; box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-weight: 800; font-size: 18px; box-shadow: 0 8px 20px rgba(79,70,229,.35);
}
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -.2px; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .12em; }
.login-title { margin: 30px 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.login-desc { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px;
  padding: 0 13px; background: #fff; color: var(--ink); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.btn {
  height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.danger { color: var(--red); border-color: #fecaca; background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.block { width: 100%; height: 48px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.login-error { min-height: 18px; color: var(--red); font-size: 12px; margin: 2px 0 10px; }
.login-foot { margin-top: 18px; text-align: center; color: #94a3b8; font-size: 11px; }

/* Shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: var(--sidebar-ink); padding: 20px 14px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 20px; }
.side-brand .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: 15px; }
.side-brand .brand-name { color: #fff; font-size: 14px; }
.side-brand .brand-sub { color: #64748b; }
.nav-group { margin: 7px 0 2px; }
.nav-label {
  width: 100%; border: 0; background: transparent; color: #94a3b8;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px;
  border-radius: 10px; font-size: 13px; font-weight: 650; text-align: left;
}
.nav-label:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-label.active { background: rgba(99,102,241,.22); color: #fff; }
.nav-label.disabled { opacity: .38; cursor: not-allowed; }
.nav-icon { width: 20px; text-align: center; font-size: 14px; opacity: .9; }
.nav-sub { margin: 2px 0 5px 16px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.08); }
.nav-sub button {
  width: 100%; border: 0; background: transparent; color: #8fa0b8; text-align: left;
  padding: 8px 10px; border-radius: 8px; font-size: 12.5px;
}
.nav-sub button:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-sub button.active { color: #fff; background: rgba(99,102,241,.22); }
.nav-sub button.disabled { opacity: .35; cursor: not-allowed; }
.side-bottom { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.side-user-name { color: #e2e8f0; font-size: 12.5px; font-weight: 650; }
.side-user-role { color: #64748b; font-size: 10.5px; }
.side-logout { width: 100%; margin-top: 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 16px; padding: 0 28px;
  background: rgba(244,246,251,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.3px; }
.topbar .crumb {
  color: var(--muted); font-size: 12px; display: flex; align-items: center;
  gap: 5px; flex-wrap: wrap;
}
.crumb-link {
  border: 0; background: transparent; padding: 0; color: var(--muted);
  font-size: 12px; cursor: pointer;
}
.crumb-link:hover { color: var(--accent); text-decoration: underline; }
.crumb-sep { color: #cbd5e1; }
.crumb-current { color: var(--muted); }
.topbar .spacer { flex: 1; }
.top-pill { padding: 6px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.content { padding: 24px 28px 40px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* Cards */
.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-title { margin: 0 0 4px; font-size: 12px; color: var(--muted); font-weight: 650; letter-spacing: .02em; }
.card-value { font-size: 26px; font-weight: 800; letter-spacing: -.7px; line-height: 1.1; }
.card-note { margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 800; }
.section-head .muted { font-size: 12px; }
.section-head .spacer { flex: 1; }
.two-col { display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* Chart */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding: 8px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 100%; width: 100%; justify-content: center; }
.bar { width: 12px; border-radius: 5px 5px 2px 2px; background: var(--accent); min-height: 2px; transition: height .3s; }
.bar.soft { background: #c7d2fe; }
.chart-label { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 0 12px 10px; white-space: nowrap; }
td { padding: 12px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
tr:hover td { background: #fbfcff; }
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.gray { background: #f1f5f9; color: #475569; }
.badge.indigo { background: var(--accent-soft); color: var(--accent); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.link-btn { border: 0; background: transparent; color: var(--accent); padding: 2px 0; font-size: 12px; font-weight: 650; }
.link-btn.danger { color: var(--red); }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

/* Forms/modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: 100%; max-width: 520px; background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.3); overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px 20px; max-height: 65vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--amber-soft); color: #92400e; font-size: 12.5px; line-height: 1.5; }
.notice.blue { background: var(--accent-soft); color: #3730a3; }
.toast { position: fixed; right: 22px; bottom: 22px; background: #0f172a; color: #fff; padding: 11px 15px; border-radius: 10px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.25); z-index: 100; }
.login-enter { animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1180px) {
  .grid.cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-brand { padding: 0 10px 0 0; }
  .nav-group { margin: 0; }
  .nav-sub { display: none; }
  .side-bottom { margin-left: auto; border: 0; padding: 0; }
  .side-user { display: none; }
  .content { padding: 18px 16px 30px; }
  .topbar { padding: 0 16px; }
  .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.nav-sub .nav-label {
  font-size: 12.5px; font-weight: 500; color: #8fa0b8;
  padding-top: 7px; padding-bottom: 7px; border-radius: 8px;
}
.nav-sub .nav-label:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-sub .nav-label.active { color: #fff; background: rgba(99,102,241,.22); }
.nav-sub .nav-sub { margin-left: 8px; padding-left: 8px; }

/* Sidebar collapse */
.side-brand { position: relative; }
.side-toggle {
  margin-left: auto; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06); color: #cbd5e1; width: 26px; height: 26px;
  border-radius: 8px; font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.side-toggle:hover { background: rgba(255,255,255,.12); color: #fff; }
.shell.collapsed { grid-template-columns: 72px minmax(0, 1fr); }
.shell.collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
.shell.collapsed .side-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.shell.collapsed .brand-copy,
.shell.collapsed .nav-text,
.shell.collapsed .nav-badge,
.shell.collapsed .nav-lock,
.shell.collapsed .side-user-copy,
.shell.collapsed .side-logout { display: none; }
.shell.collapsed .side-toggle { position: absolute; right: -11px; top: 22px; z-index: 2; background: #111a2e; }
.shell.collapsed .nav-label { justify-content: center; padding-left: 0 !important; }
.shell.collapsed .nav-sub { display: none; }
.shell.collapsed .nav-group { margin: 5px 0; }
.shell.collapsed .side-user { justify-content: center; padding: 8px 0; }

/* Nav badges / labels */
.nav-label { width: 100%; }
.nav-text { flex: 1; min-width: 0; text-align: left; }
.nav-badge {
  margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: rgba(99,102,241,.28); color: #e0e7ff;
  font-size: 10px; font-weight: 700; display: inline-flex; align-items: center;
  justify-content: center;
}
.nav-lock { margin-left: auto; font-size: 10px; color: #64748b; }
.nav-sub .nav-label { display: flex; align-items: center; gap: 6px; }

/* Status strip */
.status-strip {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.status-head {
  width: 100%; border: 0; background: transparent; display: flex; align-items: center;
  gap: 9px; padding: 11px 14px; text-align: left; color: var(--ink);
}
.status-head strong { font-size: 12.5px; }
.status-head .status-mini { color: var(--muted); font-size: 11.5px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.14); }
.status-chevron { color: var(--muted); font-size: 15px; transition: transform .18s; }
.status-strip.collapsed .status-chevron { transform: rotate(-90deg); }
.status-body {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px; padding: 0 14px 14px;
}
.status-strip.collapsed .status-body { display: none; }
.status-item {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; display: flex; flex-direction: column; gap: 2px;
}
.status-item span { font-size: 10.5px; color: var(--muted); }
.status-item b { font-size: 16px; letter-spacing: -.3px; }

/* Search / filter / pager */
.search-input {
  height: 38px; width: min(280px, 100%); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 12px; background: #fff; color: var(--ink);
  outline: none; font-size: 12.5px;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-select {
  height: 38px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 10px; background: #fff; color: var(--ink); font-size: 12.5px;
}
.pager {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 14px 2px 2px; border-top: 1px solid var(--line); margin-top: 10px;
}
.pager .spacer { flex: 1; }
.page-size { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.page-size select { height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pager-btn { height: 32px; padding: 0 12px; font-size: 12px; }
.pager-text { font-size: 12px; color: var(--muted); min-width: 54px; text-align: center; }

@media (max-width: 1180px) {
  .status-body { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell.collapsed { grid-template-columns: 1fr; }
  .shell.collapsed .brand-copy,
  .shell.collapsed .nav-text,
  .shell.collapsed .nav-badge,
  .shell.collapsed .side-user-copy,
  .shell.collapsed .side-logout { display: block; }
  .shell.collapsed .nav-sub { display: block; }
  .shell.collapsed .nav-label { justify-content: flex-start; padding-left: 10px !important; }
  .side-toggle { display: none; }
  .status-head .status-mini { display: none; }
  .status-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Batch detail */
.batch-row { cursor: pointer; }
.batch-row:hover td { background: #f5f7ff; }
.detail-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}
.detail-item {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; display: flex; flex-direction: column; gap: 3px;
}
.detail-item span { font-size: 10.5px; color: var(--muted); }
.detail-item b { font-size: 13px; font-weight: 700; }
@media (max-width: 860px) {
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Content breadcrumb */
.page-breadcrumb {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin: 0 0 12px; font-size: 11.5px; color: var(--muted);
}
.page-breadcrumb button {
  border: 0; background: transparent; padding: 0; color: var(--accent);
  font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.page-breadcrumb button:hover { text-decoration: underline; }
.page-breadcrumb .sep { color: #cbd5e1; }
.page-breadcrumb .current { color: var(--ink); font-weight: 600; }

/* 任务/账号详情 */
.task-row { cursor: pointer; }
.task-row:hover td { background: #f8fafc; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; line-height: 1.62; font-size: 13px; }
.message-list { display: flex; flex-direction: column; gap: 10px; }
.message-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.message-card .section-head { margin-bottom: 0; }
.message-card .tool-call { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #f8fafc; border: 1px solid var(--line); }
.reasoning { margin-top: 10px; }
.reasoning summary { cursor: pointer; color: var(--accent); font-size: 12px; font-weight: 700; }
.reasoning .pre-wrap { margin-top: 8px; max-height: 260px; overflow: auto; }
.detail-grid b { font-size: 13px; word-break: break-all; }
.sort-btn { border: 0; background: transparent; font: inherit; color: inherit; font-weight: 700; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.sort-btn.active { color: var(--accent); }
