/* 配色：宣纸底 + 沉香木深褐 + 琥珀（树脂）+ 青黛（信任） */
:root {
  --bg: #F4EFE7;
  --surface: #FFFDF9;
  --surface-2: #F8F3EB;
  --ink: #2A211B;
  --ink-2: #5A4D42;
  --muted: #8C7F72;
  --line: #E7DDD0;
  --side: #1C1714;
  --side-2: #262019;
  --side-ink: #BDB2A5;
  --amber: #A86F32;
  --amber-2: #C8925A;
  --amber-soft: #F3E6D3;
  --jade: #3D6B5B;
  --jade-soft: #E1ECE6;
  --danger: #B24A3B;
  --danger-soft: #F6E2DD;
  --warn: #B9822A;
  --warn-soft: #F7ECD6;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, SimSun, serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(42, 33, 27, .04), 0 4px 16px rgba(42, 33, 27, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--amber); }
.muted { color: var(--muted); }
.err { color: var(--danger); }

/* 布局 */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; overflow-y: auto; }
.brand { padding: 22px 20px 18px; border-bottom: 1px solid #2E2620; }
.brand .logo { display: flex; align-items: center; gap: 10px; }
.brand .seal { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, var(--amber-2), var(--amber)); color: #1C1714; display: grid; place-items: center; font: 700 18px var(--serif); }
.brand b { color: #F2EBE1; font: 600 16px var(--serif); letter-spacing: 1px; }
.brand small { display: block; font-size: 11px; color: #8A7E71; margin-top: 2px; }
.nav { padding: 10px 10px 20px; }
.nav h6 { margin: 16px 10px 6px; font-size: 11px; font-weight: 500; color: #6F6458; letter-spacing: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-size: 13.5px; }
.nav a:hover { background: var(--side-2); color: #EDE5DA; }
.nav a.active { background: #2D241C; color: #F3D9B4; }
.nav a.active .ico { color: var(--amber-2); }
.nav .ico { width: 18px; text-align: center; font-family: var(--serif); color: #7E7266; }
.nav .soon { margin-left: auto; font-size: 10px; padding: 0 6px; border-radius: 4px; background: #2A231D; color: #7E7266; }
.side-foot { margin-top: auto; padding: 14px 20px; font-size: 11.5px; color: #75695D; border-top: 1px solid #2E2620; }
.side-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #5E9C7F; margin-right: 6px; }

.main { overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 28px; border-bottom: 1px solid var(--line); background: rgba(244, 239, 231, .9); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.topbar h1 { margin: 0; font: 600 20px var(--serif); letter-spacing: .5px; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.page { padding: 24px 28px 40px; flex: 1; min-height: 0; }

/* 组件 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font: 600 15px var(--serif); }
.card-h .right { margin-left: auto; }
.card-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: 1.4fr 1fr; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: var(--amber-2); color: var(--amber); }
.btn-primary { background: var(--ink); color: #F6EEE3; border-color: var(--ink); }
.btn-primary:hover { background: #3A2E25; color: #fff; border-color: #3A2E25; }
.btn-amber { background: var(--amber); color: #fff; border-color: var(--amber); }
.btn-amber:hover { background: #95612A; color: #fff; }
.btn-stop { background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.amber { background: var(--amber-soft); color: #87561F; border-color: #EAD3B3; }
.tag.jade { background: var(--jade-soft); color: var(--jade); border-color: #C9DDD2; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: #EDC6BE; }
.tag.warn { background: var(--warn-soft); color: #8F6216; border-color: #EBD6AE; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--ink-2); text-align: left; }
.chip:hover { border-color: var(--amber-2); color: var(--amber); background: #FFF9F0; }
.input, select.input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); outline: none; }
.input:focus { border-color: var(--amber-2); }

/* KPI */
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .val { font: 600 26px/1.3 var(--serif); margin-top: 4px; }
.kpi .val small { font: 13px var(--sans); color: var(--muted); margin-left: 4px; }
.kpi .delta { font-size: 12px; margin-top: 4px; }
.up { color: var(--jade); } .down { color: var(--danger); }

/* 条形图 */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 92px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--amber); border-radius: 5px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* 列表/表格 */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.list li:last-child { border-bottom: 0; }
.list .what { flex: 1; min-width: 0; }
.list .what b { font-weight: 600; }
.list .what div { color: var(--muted); font-size: 12.5px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #FBF6EE; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

/* 智能体入口 */
.agent-tile { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-decoration: none; color: inherit; }
.agent-tile:hover { border-color: var(--amber-2); background: #FFF9F0; }
.glyph { flex: none; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font: 600 16px var(--serif); color: #fff; }
.agent-tile b { display: block; font-size: 13.5px; }
.agent-tile span { display: block; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* 智能体中枢 */
.hub { display: grid; grid-template-columns: 260px 1fr; gap: 16px; height: calc(100vh - 77px - 48px); }
.agent-list { overflow-y: auto; padding: 8px; }
.agent-item { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; cursor: pointer; }
.agent-item:hover { background: var(--surface-2); }
.agent-item.active { background: var(--amber-soft); }
.agent-item b { font-size: 13.5px; display: block; }
.agent-item small { color: var(--muted); font-size: 11.5px; }
.hub-chat { display: flex; flex-direction: column; min-height: 0; }
.hub-chat .card-h .glyph { width: 30px; height: 30px; font-size: 14px; }
.hub-chat .chat { flex: 1; min-height: 0; }

/* 对话组件 */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .bubble { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); line-height: 1.7; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--ink); color: #F4ECE1; border-color: var(--ink); }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble h3, .bubble h4, .bubble h5, .bubble h6 { margin: 12px 0 6px; font-family: var(--serif); }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble blockquote { margin: 0 0 8px; padding: 4px 10px; border-left: 3px solid var(--amber-2); background: var(--amber-soft); color: #7A4F1E; border-radius: 0 6px 6px 0; font-size: 12.5px; }
.bubble table { margin: 6px 0 10px; background: var(--surface); }
.bubble td, .bubble th { padding: 6px 9px; }
.bubble code { background: var(--amber-soft); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.bubble pre { background: #2A211B; color: #EDE3D6; padding: 10px; border-radius: 8px; overflow-x: auto; }
.bubble pre code { background: none; color: inherit; }
.think { margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.think summary { cursor: pointer; user-select: none; }
.think-body { white-space: pre-wrap; margin-top: 6px; padding: 8px 10px; border-left: 2px solid var(--line); max-height: 200px; overflow-y: auto; }
.typing i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--amber-2); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.chat-presets { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 18px 0; }
.chat-input { display: flex; gap: 10px; padding: 12px 18px 16px; align-items: flex-end; }
.chat-input textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface); outline: none; min-height: 40px; line-height: 1.6; }
.chat-input textarea:focus { border-color: var(--amber-2); }
.chat-input .btn { height: 40px; }
.think-toggle { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.think-toggle input { accent-color: var(--amber); margin: 0; }
.think-toggle:has(input:checked) { color: var(--amber); border-color: var(--amber-2); background: #FFF9F0; }

/* 库存 */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { padding: 9px 14px; border: 0; background: none; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--ink); border-color: var(--amber); font-weight: 600; }
.thumb { width: 40px; height: 40px; border-radius: 8px; flex: none; }
.wood { background:
  repeating-radial-gradient(ellipse at 30% 60%, rgba(0,0,0,.0) 0 3px, rgba(30,18,10,.18) 3px 4px),
  linear-gradient(135deg, #6B4A30, #3B2A1D 55%, #24190F); }
.wood.l2 { background: repeating-radial-gradient(ellipse at 70% 40%, rgba(0,0,0,0) 0 4px, rgba(30,18,10,.2) 4px 5px), linear-gradient(135deg, #8A6440, #5A3E27 60%, #3A2817); }
.wood.l3 { background: repeating-linear-gradient(100deg, rgba(0,0,0,0) 0 5px, rgba(25,15,8,.22) 5px 6px), linear-gradient(135deg, #A07850, #6E4E33 60%, #46301E); }
.cell-name { display: flex; align-items: center; gap: 10px; }
.cell-name b { font-weight: 600; display: block; }

.drawer-mask { position: fixed; inset: 0; background: rgba(28, 23, 20, .35); z-index: 20; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 96vw); background: var(--surface); z-index: 21; overflow-y: auto; box-shadow: -8px 0 32px rgba(0,0,0,.15); animation: slide .2s ease-out; }
@keyframes fade { from { opacity: 0; } } @keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-h { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.drawer-h h3 { margin: 0; font: 600 16px var(--serif); }
.drawer-h .x { margin-left: auto; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.drawer-b { padding: 20px; }
.hero { height: 180px; border-radius: 12px; position: relative; overflow: hidden; }
.hero .stamp { position: absolute; left: 14px; bottom: 12px; color: #F3E3CC; font: 600 18px var(--serif); text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.hero .stamp small { display: block; font: 12px var(--sans); opacity: .8; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; margin: 16px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.kv div { padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv div:nth-child(odd) { border-right: 1px solid var(--line); }
.kv span { display: block; color: var(--muted); font-size: 11.5px; }
.timeline { list-style: none; padding: 0; margin: 8px 0 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.timeline li::after { content: ''; position: absolute; left: 7.5px; top: 17px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline time { color: var(--muted); font-size: 12px; margin-right: 8px; }
.qr-box { display: flex; gap: 16px; align-items: center; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface-2); }
.qr-box svg { flex: none; background: #fff; padding: 6px; border-radius: 6px; }
.section-t { font: 600 14px var(--serif); margin: 20px 0 8px; }

/* 合规 */
.cp { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cp textarea { width: 100%; min-height: 200px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; padding: 12px; outline: none; background: var(--surface); line-height: 1.8; }
.marked { min-height: 120px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); line-height: 2; white-space: pre-wrap; }
mark.high { background: var(--danger-soft); color: var(--danger); border-bottom: 2px solid var(--danger); padding: 0 2px; border-radius: 3px; }
mark.mid { background: var(--warn-soft); color: #8F6216; border-bottom: 2px solid var(--warn); padding: 0 2px; border-radius: 3px; }
.score { display: flex; align-items: center; gap: 14px; }
.score .ring { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font: 600 20px var(--serif); }
.ai-panel { min-height: 160px; }
.ai-panel .bubble { background: none; border: 0; padding: 0; }

/* 手机预览 */
.phone { width: 300px; height: 620px; border-radius: 36px; border: 10px solid #1C1714; overflow: hidden; box-shadow: var(--shadow); background: #000; }
.phone iframe { width: 100%; height: 100%; border: 0; background: #fff; }

@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; } .side { display: none; }
  .g2, .cp, .hub { grid-template-columns: 1fr; } .hub { height: auto; } .hub-chat { height: 70vh; }
  .page { padding: 16px; } .topbar { padding: 14px 16px; }
}
