/* 万物OPC智能体平台 - 公共样式（本色为主，红色点缀） */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f6f5f2;
  color: #1c1c1c;
  min-height: 100vh;
}
a { color: #b02418; text-decoration: none; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e8e6e1;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.topbar .logo { font-size: 18px; font-weight: 800; letter-spacing: 0.5px; }
.topbar .logo .dot { color: #b02418; }
.topbar nav { display: flex; gap: 14px; font-size: 14px; }
.topbar nav a { color: #555; padding: 4px 2px; }
.topbar nav a.active { color: #b02418; font-weight: 600; border-bottom: 2px solid #b02418; }
.topbar .user-box { font-size: 13px; color: #666; display: flex; align-items: center; gap: 8px; }

/* 容器 */
.container { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-sub { font-size: 14px; color: #888; margin-bottom: 20px; }

/* 分类标签 */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tag {
  padding: 6px 14px; border-radius: 20px; font-size: 13px;
  background: #fff; border: 1px solid #e0ded9; color: #555; cursor: pointer;
  transition: all 0.15s;
}
.tag.active { background: #b02418; border-color: #b02418; color: #fff; }
.tag .cnt { opacity: 0.7; margin-left: 4px; font-size: 12px; }

/* 卡片网格 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: #fff; border-radius: 14px; border: 1px solid #e8e6e1;
  overflow: hidden; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.07); }
.card .cover {
  height: 110px; display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #d8d4cc, #b9b4a8);
}
.card .body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.card .name { font-size: 16px; font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.card .cat {
  font-size: 11px; color: #b02418; background: #fdf0ee;
  padding: 2px 8px; border-radius: 10px; flex-shrink: 0;
}
.card .desc { font-size: 13px; color: #777; line-height: 1.5; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { margin-top: 10px; font-size: 12px; color: #aaa; display: flex; justify-content: space-between; }

/* 按钮 */
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; border: none;
  background: #b02418; color: #fff; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn.secondary { background: #fff; color: #555; border: 1px solid #ddd; }
.btn.danger { background: #fff; color: #b02418; border: 1px solid #b02418; }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 表单 */
.form-card {
  background: #fff; border-radius: 14px; border: 1px solid #e8e6e1;
  padding: 24px; max-width: 640px;
}
.form-card .field { margin-bottom: 18px; }
.form-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #444; }
.form-card label .req { color: #b02418; }
.form-card input[type="text"], .form-card input[type="password"], .form-card input[type="tel"],
.form-card select, .form-card textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fafaf8;
}
.form-card textarea { min-height: 90px; resize: vertical; }
.form-card textarea.prompt { min-height: 180px; font-family: "SF Mono", Consolas, monospace; font-size: 13px; }
.form-card .hint { font-size: 12px; color: #999; margin-top: 4px; }
.form-card .file-drop {
  border: 2px dashed #d5d2cc; border-radius: 12px; padding: 22px; text-align: center;
  color: #999; font-size: 13px; cursor: pointer; background: #fafaf8; transition: border-color 0.15s;
}
.form-card .file-drop:hover { border-color: #b02418; color: #b02418; }
.form-card .file-list { margin-top: 8px; font-size: 13px; color: #555; }
.form-card .file-list div { padding: 4px 0; border-bottom: 1px dashed #eee; }

/* 状态徽章 */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.badge.pending { background: #fff3dc; color: #a26a00; }
.badge.approved { background: #e3f3e7; color: #1e7a3a; }
.badge.rejected { background: #fdeaea; color: #b02418; }
.badge.offline { background: #ececec; color: #777; }

/* 消息提示 */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.82); color: #fff; padding: 10px 22px;
  border-radius: 20px; font-size: 14px; z-index: 999; display: none;
}
.toast.show { display: block; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 加载 */
.loading { text-align: center; padding: 60px 0; color: #999; font-size: 14px; }
.spinner {
  width: 28px; height: 28px; border: 3px solid #e5e3de; border-top-color: #b02418;
  border-radius: 50%; margin: 0 auto 12px; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 空状态 */
.empty { text-align: center; padding: 50px 0; color: #aaa; font-size: 14px; }

/* 表格 */
.table-wrap { background: #fff; border-radius: 14px; border: 1px solid #e8e6e1; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #f0eeea; vertical-align: middle; }
th { background: #faf9f6; color: #777; font-weight: 600; font-size: 12px; }
tr:hover td { background: #fcfbf8; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid #e8e6e1; border-radius: 14px; padding: 16px 18px; }
.stat-card .num { font-size: 26px; font-weight: 800; color: #1c1c1c; }
.stat-card .lbl { font-size: 12px; color: #888; margin-top: 2px; }

/* 对话框 */
.chat-wrap { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 56px); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px 16px 10px; }
.msg { display: flex; margin-bottom: 14px; }
.msg .bubble { max-width: 82%; padding: 11px 14px; border-radius: 14px; font-size: 14px; line-height: 1.65; }
.msg.bot .bubble { background: #fff; border: 1px solid #e8e6e1; border-top-left-radius: 4px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: #b02418; color: #fff; border-top-right-radius: 4px; }
.msg .sources { width: 100%; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.msg .source-tag { font-size: 11px; color: #999; background: #f2f1ed; padding: 2px 8px; border-radius: 8px; }
.next-steps { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.next-step-btn {
  padding: 7px 14px; border-radius: 18px; font-size: 13px;
  background: #fff; border: 1px solid #dcd9d3; color: #444; cursor: pointer; transition: all 0.15s;
}
.next-step-btn:hover { border-color: #b02418; color: #b02418; background: #fdf0ee; }
.chat-input { padding: 10px 16px 16px; display: flex; gap: 10px; align-items: flex-end; }
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid #ddd; border-radius: 14px;
  padding: 12px 14px; font-size: 14px; font-family: inherit; max-height: 120px; background: #fff;
}
.chat-input .send {
  width: 44px; height: 44px; border-radius: 50%; border: none; background: #b02418; color: #fff;
  font-size: 18px; cursor: pointer; flex-shrink: 0;
}
.chat-input .send:disabled { opacity: 0.5; }

/* markdown 渲染 */
.md h1, .md h2, .md h3 { margin: 10px 0 6px; font-weight: 700; }
.md h1 { font-size: 17px; } .md h2 { font-size: 15px; } .md h3 { font-size: 14px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0 6px 20px; }
.md li { margin: 3px 0; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; min-width: 0; }
.md th, .md td { border: 1px solid #e3e1dc; padding: 5px 9px; }
.md code { background: #f2f1ed; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.md pre { background: #f5f4f1; padding: 10px 12px; border-radius: 10px; overflow-x: auto; margin: 8px 0; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid #dcd9d3; padding-left: 12px; color: #666; margin: 8px 0; }
.md strong { font-weight: 700; }

/* 登录卡 */
.auth-card { max-width: 380px; margin: 60px auto; }
.auth-tabs { display: flex; margin-bottom: 18px; background: #eee; border-radius: 10px; padding: 4px; }
.auth-tabs div { flex: 1; text-align: center; padding: 8px; font-size: 14px; border-radius: 8px; cursor: pointer; color: #666; }
.auth-tabs div.active { background: #fff; color: #b02418; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* 详情弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; max-width: 640px; width: 100%;
  max-height: 85vh; overflow-y: auto; padding: 22px;
}
.modal h3 { margin-bottom: 12px; }
.modal .kv { font-size: 13px; margin-bottom: 10px; }
.modal .kv b { color: #555; }
.modal .prompt-view { background: #f7f6f2; border-radius: 10px; padding: 12px; font-size: 12.5px; white-space: pre-wrap; max-height: 220px; overflow-y: auto; margin: 10px 0; }

@media (max-width: 600px) {
  .topbar { padding: 10px 14px; }
  .topbar nav { gap: 10px; font-size: 13px; }
  .container { padding: 14px 12px 50px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .card .cover { height: 80px; font-size: 30px; }
  .chat-wrap { height: calc(100vh - 50px); }
  .msg .bubble { max-width: 90%; }
}
