:root {
  --bg: #0b1120;
  --bg-soft: #121a2b;
  --panel: #151e31;
  --panel-2: #1b2540;
  --border: #253251;
  --text: #e6ecf7;
  --text-dim: #94a3b8;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --accent: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 10px 32px rgba(2, 6, 23, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #1e293b 0%, #0b1120 45%) no-repeat, var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; line-height: 1.35; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex: none; background: rgba(15, 23, 42, 0.9);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand .logo { font-size: 18px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.brand .sub { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.nav { padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 9px 12px; margin-bottom: 2px;
  background: transparent; border: none; color: var(--text-dim); border-radius: 9px; cursor: pointer; font-size: 13.5px; font-family: inherit;
}
.nav button:hover { background: rgba(59, 130, 246, .1); color: var(--text); }
.nav button.active { background: rgba(59, 130, 246, .18); color: #fff; font-weight: 500; }
.nav .group { padding: 14px 12px 6px; font-size: 11px; color: #556076; letter-spacing: .08em; text-transform: uppercase; }
.side-foot { padding: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 14px; flex-wrap: wrap; }
.topbar .right { display: flex; align-items: center; gap: 10px; }

/* ---------- 组件 ---------- */
.card {
  background: linear-gradient(180deg, rgba(27, 37, 64, .85), rgba(21, 30, 49, .85));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card.tight { padding: 14px 16px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.stat { background: rgba(15, 23, 42, .6); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--text-dim); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: .4px; }
.stat .hint { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

button.btn, .btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); padding: 8px 14px; border-radius: 9px;
  cursor: pointer; font-size: 13.5px; font-family: inherit; transition: all .15s ease; white-space: nowrap;
}
button.btn:hover, .btn:hover { border-color: #3d4d75; background: #223058; }
button.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-color: transparent; color: #fff; font-weight: 500; }
button.btn.primary:hover { filter: brightness(1.08); }
button.btn.ghost { background: transparent; }
button.btn.danger { border-color: rgba(239, 68, 68, .5); color: #fca5a5; }
button.btn.danger:hover { background: rgba(239, 68, 68, .14); }
button.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  width: 100%; background: #0e1626; border: 1px solid var(--border); color: var(--text); border-radius: 9px;
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, .16); }
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; }
.inline { display: flex; gap: 10px; align-items: center; }
.inline input[type=checkbox] { width: auto; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: rgba(148, 163, 184, .14); color: var(--text-dim); }
.pill.green { background: rgba(16, 185, 129, .16); color: #6ee7b7; }
.pill.blue { background: rgba(59, 130, 246, .18); color: #93c5fd; }
.pill.amber { background: rgba(245, 158, 11, .16); color: #fcd34d; }
.pill.red { background: rgba(239, 68, 68, .16); color: #fca5a5; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid rgba(37, 50, 81, .7); vertical-align: top; }
th { color: var(--text-dim); font-weight: 500; font-size: 12.5px; }
tbody tr:hover { background: rgba(59, 130, 246, .05); }
.muted { color: var(--text-dim); }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.pre {
  background: #0a1120; border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; max-height: 340px; white-space: pre-wrap; word-break: break-word;
}
.empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.bar { height: 8px; border-radius: 999px; background: rgba(148, 163, 184, .16); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); }

/* ---------- 对话 ---------- */
.chat { display: flex; flex-direction: column; height: 520px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; background: rgba(10, 17, 32, .6); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.bubble.user { align-self: flex-end; background: var(--primary-dark); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble .meta { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; }
.bubble code { background: rgba(148,163,184,.15); padding: 1px 5px; border-radius: 5px; }
.cites { margin-top: 8px; padding-top: 7px; border-top: 1px dashed rgba(148,163,184,.3); font-size: 12px; color: var(--text-dim); }
.tool-event { align-self: flex-start; font-size: 12px; color: #7dd3fc; background: rgba(14, 165, 233, .12); border: 1px solid rgba(14, 165, 233, .28); border-radius: 8px; padding: 5px 10px; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input textarea { min-height: 44px; max-height: 130px; }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(2, 6, 23, .68); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: min(880px, 100%); max-height: 88vh; overflow: auto; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--panel); z-index: 2; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--panel); }

.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--primary); padding: 11px 15px; border-radius: 9px; box-shadow: var(--shadow); font-size: 13px; max-width: 380px; animation: slide .2s ease; }
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--accent); }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } }

/* ---------- 登录 ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: min(430px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card .brandline { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.tabs { display: flex; gap: 6px; margin: 18px 0; background: rgba(15,23,42,.7); padding: 4px; border-radius: 10px; }
.tabs button { flex: 1; padding: 8px; border: none; background: transparent; color: var(--text-dim); border-radius: 7px; cursor: pointer; font-family: inherit; font-size: 13.5px; }
.tabs button.active { background: var(--panel-2); color: #fff; }

/* ---------- 行业包 ---------- */
.pack { background: rgba(15,23,42,.55); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; display: flex; flex-direction: column; gap: 9px; transition: border-color .15s; }
.pack:hover { border-color: rgba(59,130,246,.5); }
.pack .icon { font-size: 26px; }
.pack .name { font-weight: 600; font-size: 15px; }
.pack .summary { color: var(--text-dim); font-size: 12.5px; flex: 1; }
.pack .kpi { font-size: 12px; color: var(--text-dim); }

.cat-title { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.cat-title h3 { margin: 0; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav .group { display: none; }
  .nav button { width: auto; }
  .main { padding: 16px; }
}
