:root {
  --bg: #ffffff;
  --side: #f7f8f8;
  --line: #e8eaea;
  --line-soft: #f0f1f1;
  --ink: #16201c;
  --ink-2: #5b6763;
  --ink-3: #8b9793;
  --green: #1f8a5b;
  --green-dark: #17714a;
  --green-soft: #eaf5ef;
  --amber: #e08c1a;
  --blue: #2f6fd0;
  --violet: #6f4fd0;
  --red: #c8392f;
  --radius: 14px;
  --radius-lg: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font: 15px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei",
        "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

svg { width: 18px; height: 18px; flex: none; }

.layout { display: flex; height: 100%; }

/* ---------- 侧边栏 ---------- */

.side {
  width: 252px; flex: none;
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 14px 12px;
  transition: width .18s ease, padding .18s ease;
}
.side.collapsed { width: 0; padding: 14px 0; overflow: hidden; }

.side-top { display: flex; align-items: center; gap: 8px; padding: 2px 6px 18px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px;
  background: var(--green); color: #fff;
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: .2px; white-space: nowrap; }

.icon-btn {
  width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-3);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: #ebeeed; color: var(--ink-2); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none;
  font-size: 14.5px; white-space: nowrap; cursor: pointer;
}
.nav-item:hover { background: #edefee; color: var(--ink); }
.nav-item.active { background: #e7eae9; color: var(--ink); font-weight: 600; }
.nav-item.active svg { color: var(--green); }
.nav-item.small { font-size: 14px; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.whoami {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px 4px; margin-top: 8px;
  border-top: 1px solid var(--line);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.whoami-text { min-width: 0; }
.whoami-name { font-size: 13.5px; font-weight: 600; }
.whoami-sub {
  font-size: 12px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 主区 ---------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px; flex: none;
}
.topbar-spacer { flex: 1; }
.only-narrow { display: none; }

.worker-chip {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink-2);
  background: #f2f4f3; border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px;
}
.worker-chip .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #c2c8c6;
}
.worker-chip.on .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.worker-chip.on { color: var(--green-dark); border-color: #cfe6da; background: var(--green-soft); }

.btn-primary {
  display: flex; align-items: center; gap: 7px;
  background: var(--green); color: #fff; border: 0;
  padding: 9px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary.wide { width: 100%; justify-content: center; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view.hidden { display: none; }
.hidden { display: none !important; }

.scroll { flex: 1; overflow-y: auto; padding: 0 24px; }

.hero { max-width: 900px; margin: 34px auto 10px; }
.hero.gone { display: none; }
.hero-kicker { margin: 0 0 6px; color: var(--ink-3); font-size: 15px; }
.hero-title { margin: 0 0 26px; font-size: 38px; line-height: 1.22; font-weight: 700; letter-spacing: -.5px; }

/* ---------- 输入框 ---------- */

.composer-wrap { padding: 0 24px; flex: none; }
.composer {
  max-width: 900px; margin: 0 auto;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: #fff; padding: 16px 16px 10px;
  position: relative;
}
.composer:focus-within { border-color: #cfd8d4; box-shadow: 0 1px 3px rgba(20,30,25,.05); }
.composer textarea {
  width: 100%; border: 0; outline: 0; resize: none;
  font: inherit; color: var(--ink);
  min-height: 84px; max-height: 260px; background: transparent;
}
.composer textarea::placeholder { color: var(--ink-3); }
.counter { text-align: right; font-size: 12.5px; color: var(--ink-3); padding: 2px 2px 8px; }

.composer-bar {
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--line-soft); padding-top: 10px;
}
.composer-spacer { flex: 1; }

.chip {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: #fff;
  color: var(--ink-2); font: inherit; font-size: 13.5px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.chip:hover { background: #f6f7f7; }
.chip.on { background: var(--green-soft); border-color: #cfe6da; color: var(--green-dark); }
.chip.on svg { color: var(--green); }
.chip.warn { background: #fdf2f1; border-color: #f0d2ce; color: var(--red); }
.chip.warn svg { color: var(--red); }
.chip svg { width: 16px; height: 16px; }

.send {
  width: 40px; height: 34px; border: 0; border-radius: 9px;
  background: var(--green); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.send:hover { background: var(--green-dark); }
.send:disabled { background: #cdd4d1; cursor: default; }

/* ---------- 常用卡片 ---------- */

.ready { max-width: 900px; margin: 0 auto; padding: 34px 24px 40px; width: 100%; }
.ready.gone { display: none; }
.ready-title { margin: 0 0 16px; font-size: 19px; font-weight: 700; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.card {
  text-align: left; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; padding: 18px 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 9px; font: inherit;
}
.card:hover { border-color: #d5dcd9; background: #fbfcfc; }
.card-icon { width: 30px; height: 30px; display: grid; place-items: center; }
.card-icon svg { width: 22px; height: 22px; }
.ic-blue { color: var(--blue); }
.ic-amber { color: var(--amber); }
.ic-green { color: var(--green); }
.ic-violet { color: var(--violet); }
.card-title { font-weight: 650; font-size: 15px; }
.card-desc { color: var(--ink-2); font-size: 13px; line-height: 1.55; }

/* ---------- 对话 ---------- */

.thread { max-width: 900px; margin: 0 auto 24px; display: flex; flex-direction: column; gap: 18px; }
.turn { display: flex; gap: 12px; }
.turn .who {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.turn.me .who { background: #e7eae9; color: var(--ink-2); }
.turn.ai .who { background: var(--green); color: #fff; }
.bubble { min-width: 0; flex: 1; padding-top: 3px; }
.bubble p { margin: 0 0 9px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble pre {
  background: #f7f8f8; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bubble code {
  background: #f2f4f3; border-radius: 5px; padding: 1px 5px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bubble pre code { background: none; padding: 0; }
.bubble table { border-collapse: collapse; font-size: 13.5px; margin: 4px 0 10px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.bubble th { background: #f7f8f8; font-weight: 600; }

.tool-card {
  border: 1px solid var(--line); border-radius: 12px;
  background: #fbfcfc; padding: 12px 14px; margin: 8px 0;
  font-size: 13.5px;
}
.tool-head { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.tool-head .spin {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid #d9dfdc; border-top-color: var(--green);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tool-name { font-weight: 600; color: var(--ink); }
.tool-body { margin-top: 8px; }
.tool-body dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.tool-body dt { color: var(--ink-3); }
.tool-body dd { margin: 0; }

.confirm {
  border: 1px solid #f0d2ce; background: #fdf7f6; border-radius: 12px;
  padding: 14px 16px; margin: 10px 0;
}
.confirm h4 { margin: 0 0 4px; font-size: 14.5px; color: var(--red); }
.confirm .why { color: var(--ink-2); font-size: 13.5px; margin: 0 0 10px; }
.confirm-actions { display: flex; gap: 9px; }
.btn-danger {
  background: var(--red); color: #fff; border: 0; border-radius: 9px;
  padding: 8px 18px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: #ac3027; }
.btn-plain {
  background: #fff; color: var(--ink-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 18px; font: inherit; cursor: pointer;
}
.btn-plain:hover { background: #f6f7f7; }
.done-note { color: var(--ink-3); font-size: 13px; }

.placeholder { max-width: 900px; margin: 30px auto; }

/* ---------- 登录 ---------- */

.modal-back {
  position: fixed; inset: 0; background: rgba(16,24,20,.32);
  display: grid; place-items: center; z-index: 40;
}
.modal {
  width: 340px; background: #fff; border-radius: 16px;
  padding: 26px 24px; box-shadow: 0 18px 50px rgba(16,24,20,.18);
}
.modal h2 { margin: 0 0 6px; font-size: 20px; }
.modal-sub { margin: 0 0 18px; color: var(--ink-2); font-size: 13.5px; line-height: 1.55; }
.modal input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font: inherit; outline: 0; margin-bottom: 10px;
}
.modal input:focus { border-color: var(--green); }
.modal-err { color: var(--red); font-size: 13px; min-height: 19px; margin-bottom: 6px; }

@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .side { position: fixed; z-index: 30; height: 100%; box-shadow: 0 0 40px rgba(0,0,0,.12); }
  .side.collapsed { box-shadow: none; }
  .only-narrow { display: grid; }
  .cards { grid-template-columns: 1fr; }
  .hero-title { font-size: 28px; }
}

/* ---------- 内容页 ---------- */

.page { max-width: 1040px; margin: 8px auto 48px; }
.page-head {
  display: flex; align-items: flex-start; gap: 16px;
  margin: 18px 0 22px;
}
.page-head > div:first-child { flex: 1; }
.head-tools { display: flex; gap: 9px; align-items: center; }
.page-title { margin: 0 0 4px; font-size: 27px; font-weight: 700; letter-spacing: -.3px; }
.page-sub { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.page-body { min-height: 60px; }

.select {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 9px 12px; font: inherit; font-size: 14px; color: var(--ink-2);
  cursor: pointer; outline: 0;
}

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; background: #fff;
}
.stat-k { color: var(--ink-3); font-size: 12.5px; margin-bottom: 5px; }
.stat-v { font-size: 27px; font-weight: 700; line-height: 1.15; }
.stat-v.zero { color: var(--ink-3); font-weight: 600; }
.stat-sub { color: var(--ink-3); font-size: 12px; margin-top: 3px; }

.block { margin-bottom: 26px; }
.block-title {
  font-size: 15px; font-weight: 650; margin: 0 0 10px;
  display: flex; align-items: center; gap: 9px;
}
.pill {
  background: #eef1f0; color: var(--ink-2); border-radius: 999px;
  padding: 1px 9px; font-size: 12px; font-weight: 500;
}
.pill.bad { background: #fdeceb; color: var(--red); }
.pill.good { background: var(--green-soft); color: var(--green-dark); }

.tbl-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.tbl th, table.tbl td {
  padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
table.tbl th { background: #f7f8f8; font-weight: 600; color: var(--ink-2); position: sticky; top: 0; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.wrap { white-space: normal; min-width: 260px; max-width: 460px; }
table.tbl tr:hover td { background: #fbfcfc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.empty { color: var(--ink-3); padding: 26px 2px; font-size: 14px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-2); padding: 22px 2px; }
.loading .spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #d9dfdc; border-top-color: var(--green);
  animation: spin .7s linear infinite;
}
.errbox {
  border: 1px solid #f0d2ce; background: #fdf7f6; border-radius: 12px;
  padding: 13px 15px; color: var(--red); font-size: 13.5px;
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
