:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --ink: #1d2329;
  --muted: #6b7280;
  --line: #e3e1db;
  --accent: #9a2f2f;
  --accent-soft: #f6ecea;
  --green: #2f6b4f;
  --blue: #2c4a6e;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

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

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  flex: 0 0 210px;
  background: #1f2528;
  color: #cfd4d6;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.brand span { font-size: 12px; color: #8d989c; font-weight: 400; letter-spacing: 2px; }

.sidebar nav { margin-top: 28px; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav .group {
  font-size: 11px; color: #78858a; margin: 18px 10px 6px; letter-spacing: 1px;
}
.sidebar nav a {
  color: #cfd4d6; padding: 8px 10px; border-radius: 6px; font-size: 13.5px;
}
.sidebar nav a:hover { background: #2b3337; text-decoration: none; }
.sidebar nav a.active { background: #343d41; color: #fff; }

.sidebar-foot {
  position: absolute; bottom: 20px; left: 16px; right: 16px;
  font-size: 11px; color: #6f7b80; line-height: 1.5;
}

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

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; border-bottom: 1px solid var(--line); background: #fbfaf7;
  position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 17px; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.topbar-user form { margin: 0; }
.topbar-user button {
  background: none; border: 1px solid var(--line); color: var(--muted);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.topbar-user button:hover { color: var(--accent); border-color: var(--accent); }

.content { padding: 26px 32px 48px; max-width: 1440px; width: 100%; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.card .label { font-size: 12px; color: var(--muted); }
.card .value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -0.5px; }
.card .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-top: 20px;
}
.panel h2 { font-size: 14px; font-weight: 600; margin: 0 0 14px; }
.panel .panel-hint { font-size: 12px; color: var(--muted); margin-top: -8px; margin-bottom: 12px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 500;
  border-bottom: 1px solid var(--line); padding: 8px 8px; white-space: nowrap;
}
td { padding: 9px 8px; border-bottom: 1px solid #efede8; vertical-align: top; font-size: 13px; }
tr:hover td { background: #fbfaf6; }
td.title { max-width: 520px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px;
  background: #eef0f1; color: #4b5563; white-space: nowrap;
}
.tag.self { background: #eaf3ec; color: var(--green); }
.tag.industry { background: #eef1f6; color: var(--blue); }
.tag.level { background: var(--accent-soft); color: var(--accent); }
.tag.vacant { background: #f3f0e2; color: #8a6d1f; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px;
}
.filters label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.filters input, .filters select {
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 13px;
  background: #fff; color: var(--ink); min-width: 120px;
}
.filters input[type="text"] { min-width: 220px; }
.filters button, .btn {
  background: var(--ink); color: #fff; border: none; border-radius: 6px;
  padding: 7px 16px; font-size: 13px; cursor: pointer;
}
.filters button:hover, .btn:hover { background: #000; text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--accent); }
.btn.small { padding: 3px 10px; font-size: 12px; }

.pagination { display: flex; gap: 10px; align-items: center; margin-top: 16px; font-size: 13px; }
.pagination a, .pagination span {
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.pagination .muted { color: var(--muted); border: none; background: none; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 60px; gap: 10px; align-items: center; }
.bar-row .name { font-size: 12px; color: var(--muted); text-align: right; }
.bar { height: 8px; background: #ece9e2; border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-row .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 24px;
}
.detail-item .k { font-size: 11px; color: var(--muted); }
.detail-item .v { font-size: 13px; margin-top: 1px; word-break: break-all; }

.notice {
  background: #fdf8e6; border: 1px solid #efe2b4; color: #74570e;
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 12px 0;
}
.notice.error { background: #fbeceb; border-color: #efc9c5; color: #8c2a24; }
.notice.ok { background: #eaf3ec; border-color: #c8e0cf; color: #255c40; }

.prose { white-space: pre-wrap; font-size: 13.5px; line-height: 1.85; }
.section-title {
  font-size: 13px; font-weight: 600; margin: 22px 0 8px; padding-left: 8px;
  border-left: 3px solid var(--accent);
}

.empty { color: var(--muted); text-align: center; padding: 32px 0; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #1f2528 0%, #2d3539 60%, #3a2f2d 100%);
}
.login-card {
  width: 360px; background: #fff; border-radius: 14px; padding: 34px 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: 1px; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 12px; letter-spacing: 2px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 4px; }
.login-card input[type="text"], .login-card input[type="password"] {
  width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px;
  font-size: 14px;
}
.login-card .row { display: flex; align-items: center; gap: 6px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.login-card button {
  width: 100%; margin-top: 20px; padding: 10px; border: none; border-radius: 7px;
  background: var(--ink); color: #fff; font-size: 14px; cursor: pointer;
}
.login-card button:hover { background: #000; }
.login-foot { text-align: center; font-size: 11px; color: #9aa3a6; margin-top: 18px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
/* 报送表单材料区：单列全宽（与官网申报表单一致），一行一个字段 */
.material-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.material-grid > div { min-width: 0; }
.material-grid label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; color: var(--ink); }
.material-grid input, .material-grid select, .material-grid textarea { max-width: 640px; }
.material-grid .small { margin-top: 4px; }
.form-grid label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.form-grid input, .form-grid select {
  width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 13px;
}

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; padding: 14px 16px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; margin-top: 10px; }
  .sidebar-foot { display: none; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .two-col { grid-template-columns: 1fr; }
  td.title { max-width: none; }
}

/* ---------------------------------------------------------------- AI 助手 */
.ai-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.ai-side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.ai-conv-list { margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.ai-conv { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-radius: 6px; }
.ai-conv:hover { background: var(--bg, #f5f6f8); }
.ai-conv.active { background: rgba(43,108,176,.12); }
.ai-conv-title { flex: 1; color: inherit; text-decoration: none; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-conv-del { border: 0; background: none; color: var(--muted, #999); cursor: pointer; font-size: 14px; padding: 0 4px; }
.ai-conv-del:hover { color: var(--danger, #c0392b); }
.ai-main { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0; display: flex; flex-direction: column; min-height: 65vh; }
.ai-messages { flex: 1; overflow-y: auto; padding: 18px; max-height: 62vh; }
.ai-empty { text-align: center; margin-top: 18vh; color: var(--muted, #888); }
.ai-empty-title { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.ai-empty-hint { font-size: 13px; line-height: 1.8; }
.ai-msg { display: flex; margin-bottom: 12px; }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-assistant { justify-content: flex-start; flex-direction: column; }
.ai-bubble { max-width: 78%; padding: 9px 13px; border-radius: 10px; font-size: 13.5px; line-height: 1.65; }
.ai-msg-user .ai-bubble { background: #2b6cb0; color: #fff; }
.ai-msg-assistant .ai-bubble { background: var(--bg, #f5f6f8); color: inherit; }
.ai-status { font-size: 12px; color: var(--muted, #888); margin-bottom: 6px; }
.ai-cites { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; font-size: 12px; color: var(--muted, #888); }
.ai-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.ai-input textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 13.5px; font-family: inherit; }

/* AI 消息 Markdown 渲染 */
.ai-msg-assistant .ai-bubble.prose { white-space: normal; }
.ai-bubble.prose p { margin: 0 0 8px; }
.ai-bubble.prose p:last-child { margin-bottom: 0; }
.ai-bubble.prose ul, .ai-bubble.prose ol { margin: 0 0 8px; padding-left: 20px; }
.ai-bubble.prose li { margin: 2px 0; }
.ai-bubble.prose h1, .ai-bubble.prose h2, .ai-bubble.prose h3, .ai-bubble.prose h4 { margin: 10px 0 6px; font-size: 14.5px; line-height: 1.4; }
.ai-bubble.prose > :first-child { margin-top: 0; }
.ai-bubble.prose > :last-child { margin-bottom: 0; }
.ai-bubble.prose code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.ai-bubble.prose pre { background: rgba(0,0,0,.06); padding: 8px 10px; border-radius: 6px; overflow-x: auto; margin: 0 0 8px; }
.ai-bubble.prose pre code { background: none; padding: 0; }
.ai-bubble.prose blockquote { margin: 0 0 8px; padding: 2px 10px; border-left: 3px solid var(--line); color: var(--muted); }
.ai-bubble.prose table { border-collapse: collapse; margin: 4px 0 10px; font-size: 12.5px; max-width: 100%; display: block; overflow-x: auto; white-space: normal; }
.ai-bubble.prose th, .ai-bubble.prose td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.ai-bubble.prose th { background: rgba(0,0,0,.045); font-weight: 600; }
.ai-bubble.prose hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
