/* ShenaAI 智能资产评估 · 多端 PWA
   混合设计：ShenaAI 暗色玻璃态骨架（蓝）+ 朱砂/金 古典强调（呼应虎符/五等爵） */

:root {
  /* —— ShenaAI 平台基色 —— */
  --bg-dark: #020617;
  --bg-panel: #0f172a;
  --bg-glass: rgba(15, 23, 42, .62);
  --bg-glass-2: rgba(30, 41, 59, .55);
  --border: rgba(148, 163, 184, .16);
  --border-strong: rgba(148, 163, 184, .30);
  --accent-blue: #38bdf8;
  --accent-purple: #818cf8;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;
  /* —— 古典强调（产品个性）—— */
  --cinnabar: #e0644f;      /* 朱砂：虎符/印/critical */
  --cinnabar-deep: #c0392b;
  --gold: #fbbf24;          /* 金：五等爵/key */
  /* —— 语义 —— */
  --sev-stop: #f0705a;
  --sev-error: #f0705a;
  --sev-warning: #fbbf24;
  --sev-ok: #34d399;
  --sev-info: #38bdf8;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 18px 46px -22px rgba(0,0,0,.7);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --sans: "Outfit", "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --nav-w: 15.5rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg-dark); color: var(--text-primary);
  font-family: var(--body); line-height: 1.6; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(60rem 40rem at 82% -8%, rgba(56,189,248,.10), transparent 60%),
    radial-gradient(48rem 32rem at 6% 4%, rgba(224,100,79,.09), transparent 55%);
  background-attachment: fixed;
}
a { color: var(--accent-blue); text-decoration: none; }
::selection { background: rgba(224,100,79,.32); }
:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; border-radius: 4px; }
h1,h2,h3,h4 { font-family: var(--sans); font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0; }

/* ================= 布局骨架 ================= */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }

/* 顶栏 */
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: .9rem;
  padding: .7rem clamp(.9rem, 3vw, 1.7rem); position: sticky; top: 0; z-index: 30;
  background: rgba(2,6,23,.72); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--sans); font-weight: 600; text-decoration: none; color: inherit; }
.brand:hover .name { color: var(--text-primary); }
.brand:hover .seal { box-shadow: 0 0 0 3px rgba(224,100,79,.16); }
.home-btn { flex: none; }
.seal {
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px;
  border: 1.5px solid var(--cinnabar); color: var(--cinnabar); font-size: .95rem; font-weight: 700;
  transform: rotate(-4deg); flex: none;
  box-shadow: 0 0 0 3px rgba(224,100,79,.08);
}
.brand .name { font-size: 1.02rem; letter-spacing: .01em; }
.brand .name b { color: var(--accent-blue); }
.brand .sub { font-size: .72rem; color: var(--text-dim); font-family: var(--body); font-weight: 400; }
.topbar-spacer { flex: 1; }
.chip {
  font-family: var(--mono); font-size: .72rem; color: var(--text-secondary);
  background: var(--bg-glass-2); border: 1px solid var(--border); border-radius: 20px; padding: .28rem .66rem;
  white-space: nowrap;
}
.chip b { color: var(--gold); font-weight: 600; }
.btn {
  font-family: var(--sans); font-weight: 500; font-size: .86rem; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-glass-2); color: var(--text-primary);
  padding: .5rem .95rem; border-radius: 10px; transition: all .2s var(--ease); display: inline-flex; gap: .45rem; align-items: center;
}
.btn:hover { border-color: var(--accent-blue); background: rgba(56,189,248,.12); }
.btn.primary { background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple)); border-color: transparent; color: #04121f; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.cinnabar { border-color: rgba(224,100,79,.5); color: var(--cinnabar); }
.btn.cinnabar:hover { background: rgba(224,100,79,.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
#installBtn { display: none; }

/* 导航（桌面侧栏） */
.nav {
  position: sticky; top: 3.4rem; align-self: start; height: calc(100vh - 3.4rem);
  padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: .2rem;
  border-right: 1px solid var(--border); overflow-y: auto;
}
.nav a {
  display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 10px;
  color: var(--text-secondary); font-size: .92rem; font-weight: 500; transition: all .18s var(--ease); border: 1px solid transparent;
}
.nav a .ic { width: 1.15rem; text-align: center; opacity: .85; }
.nav a:hover { color: var(--text-primary); background: var(--bg-glass-2); }
.nav a.active { color: var(--text-primary); background: rgba(56,189,248,.12); border-color: rgba(56,189,248,.28); }
.nav a.active .ic { color: var(--accent-blue); opacity: 1; }
.nav .nav-foot { margin-top: auto; padding: .8rem; font-size: .72rem; color: var(--text-dim); line-height: 1.5; }
.nav .nav-foot b { color: var(--text-secondary); }

/* 主区 */
.main { padding: clamp(1.1rem, 3vw, 2.4rem) clamp(1rem, 3.5vw, 2.6rem); max-width: 74rem; width: 100%; }
.view { display: none; animation: fade .3s var(--ease); }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 1.6rem; }
.eyebrow { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--cinnabar); font-weight: 600; margin-bottom: .5rem; }
.view-head h1 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); }
.view-head p { color: var(--text-secondary); margin: .5rem 0 0; max-width: 60ch; }

/* ================= 组件 ================= */
.panel {
  background: var(--bg-glass); backdrop-filter: blur(10px); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.3rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.2rem;
}
.panel h2 { font-size: 1.1rem; margin-bottom: .9rem; display: flex; align-items: center; gap: .5rem; }
.panel h2 .bar { width: 3px; height: 1.05rem; background: var(--cinnabar); border-radius: 2px; }

.grid { display: grid; gap: 1rem; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--bg-glass); padding: 1.05rem 1.1rem; }
.stat .k { font-size: .74rem; color: var(--text-dim); margin-bottom: .4rem; }
.stat .v { font-family: var(--sans); font-weight: 700; font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .v.accent { color: var(--gold); }
.stat .v.blue { color: var(--accent-blue); }
.stat .v small { font-size: .72rem; font-weight: 400; color: var(--text-dim); font-family: var(--body); }

.card { background: var(--bg-glass); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.1rem 1.15rem; transition: all .2s var(--ease); }
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card h3 { font-size: 1rem; margin-bottom: .4rem; }
.card p { color: var(--text-secondary); font-size: .88rem; margin: 0; }
.card .tag { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--cinnabar); font-weight: 700; margin-bottom: .45rem; }

/* 严重度 chip / dot */
.sev { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--mono); font-size: .74rem; padding: .18rem .55rem; border-radius: 6px; white-space: nowrap; }
.sev.stop, .sev.error { color: var(--sev-stop); background: rgba(240,112,90,.12); border: 1px solid rgba(240,112,90,.34); }
.sev.warning { color: var(--sev-warning); background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.3); }
.sev.info { color: var(--sev-info); background: rgba(56,189,248,.1); border: 1px solid rgba(56,189,248,.28); }
.sev.ok { color: var(--sev-ok); background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.3); }

.status-pill { font-family: var(--sans); font-weight: 600; font-size: .82rem; padding: .35rem .8rem; border-radius: 20px; display: inline-flex; gap: .5rem; align-items: center; }
.status-pill::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.status-pill.analysis_ready { color: var(--sev-ok); background: rgba(52,211,153,.12); }
.status-pill.conditional { color: var(--gold); background: rgba(251,191,36,.12); }
.status-pill.not_ready, .status-pill.prohibited_use { color: var(--sev-stop); background: rgba(240,112,90,.12); }
.status-pill.professional_review_required { color: var(--accent-purple); background: rgba(129,140,248,.14); }

/* findings 列表 */
.findings { display: grid; gap: .5rem; }
.finding { display: grid; grid-template-columns: auto 1fr; gap: .7rem; padding: .7rem .85rem; background: var(--bg-glass-2); border: 1px solid var(--border); border-radius: 10px; align-items: start; }
.finding .code { font-family: var(--mono); font-size: .78rem; color: var(--text-primary); font-weight: 600; }
.finding .msg { color: var(--text-secondary); font-size: .85rem; margin-top: .15rem; }

/* coverage 条 */
.cov { display: grid; gap: .7rem; }
.cov-row { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; align-items: center; }
.cov-row .label { font-size: .86rem; color: var(--text-primary); }
.cov-row .pct { font-family: var(--mono); font-size: .82rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cov-bar { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: var(--bg-glass-2); overflow: hidden; }
.cov-bar > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple)); transition: width .5s var(--ease); }
.cov-bar.partial > i { background: linear-gradient(90deg, var(--gold), var(--cinnabar)); }

/* 表单 */
.form-row { display: grid; gap: .4rem; margin-bottom: 1rem; }
.form-row label { font-size: .84rem; color: var(--text-secondary); }
textarea, input[type="text"], input[type="search"], select {
  width: 100%; font-family: var(--mono); font-size: .84rem; color: var(--text-primary);
  background: var(--bg-dark); border: 1px solid var(--border-strong); border-radius: 10px; padding: .7rem .8rem; resize: vertical;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent-blue); outline: none; }
textarea { min-height: 9rem; }
.search-bar { display: flex; gap: .6rem; }
.search-bar input { flex: 1; font-family: var(--body); }

/* 工作台：表单/JSON 双模式 */
.wb-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .4rem; }
.tabs { display: inline-flex; background: var(--bg-glass-2); border: 1px solid var(--border); border-radius: 10px; padding: .2rem; }
.tab { font-family: var(--sans); font-size: .84rem; font-weight: 500; color: var(--text-secondary); background: transparent; border: none; padding: .42rem .95rem; border-radius: 8px; cursor: pointer; transition: all .18s var(--ease); }
.tab.active { background: rgba(56,189,248,.16); color: var(--text-primary); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .9rem 1.1rem; }
.form-grid .form-row { margin-bottom: 0; }
.chk-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.chk { display: inline-flex; align-items: center; gap: .45rem; font-size: .82rem; color: var(--text-secondary); background: var(--bg-glass-2); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .72rem; cursor: pointer; user-select: none; transition: all .16s var(--ease); }
.chk input { accent-color: var(--accent-blue); margin: 0; }
.chk.on { border-color: rgba(56,189,248,.42); color: var(--text-primary); background: rgba(56,189,248,.08); }
.form-section-label { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; color: var(--text-dim); margin: 1.2rem 0 .55rem; font-weight: 600; }

/* RAG passage */
.passage { background: var(--bg-glass); border: 1px solid var(--border); border-left: 3px solid var(--accent-blue); border-radius: 0 10px 10px 0; padding: .9rem 1.1rem; margin-bottom: .8rem; }
.passage .cite { font-size: .8rem; color: var(--gold); font-weight: 600; margin-bottom: .4rem; display: flex; justify-content: space-between; gap: .8rem; }
.passage .cite .score { font-family: var(--mono); color: var(--text-dim); font-weight: 400; }
.passage .txt { font-size: .88rem; color: var(--text-secondary); white-space: pre-wrap; max-height: 8rem; overflow: hidden; position: relative; }
.passage .tags { margin-top: .5rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.passage .tags .t { font-family: var(--mono); font-size: .68rem; color: var(--accent-purple); background: rgba(129,140,248,.1); border-radius: 4px; padding: .1rem .4rem; }
.gap-note { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.3); color: var(--gold); padding: .7rem .9rem; border-radius: 10px; font-size: .85rem; margin-bottom: .9rem; }

/* 报告 markdown */
.report { background: var(--bg-dark); border: 1px solid var(--border); border-radius: 12px; padding: 1.2rem 1.4rem; max-height: 32rem; overflow: auto; font-size: .86rem; }
.report h1 { font-size: 1.2rem; margin: .3rem 0 .8rem; }
.report h2 { font-size: 1rem; color: var(--accent-blue); margin: 1.1rem 0 .5rem; }
.report table { border-collapse: collapse; width: 100%; margin: .5rem 0; font-size: .82rem; }
.report th, .report td { border: 1px solid var(--border); padding: .35rem .55rem; text-align: left; }
.report code { font-family: var(--mono); background: var(--bg-glass-2); padding: .05rem .3rem; border-radius: 4px; }
.report ul { padding-left: 1.2rem; }

.rec-row { cursor: pointer; transition: background .15s var(--ease); }
.rec-row:hover td { background: rgba(56,189,248,.08); }
.muted { color: var(--text-dim); font-size: .82rem; }
.spinner { width: 1.1rem; height: 1.1rem; border: 2px solid var(--border-strong); border-top-color: var(--accent-blue); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.overflow-x { overflow-x: auto; }

.disclaimer { margin-top: 2rem; padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-glass); color: var(--text-dim); font-size: .78rem; line-height: 1.6; }
.disclaimer b { color: var(--cinnabar); }

/* ================= 响应式：移动端底部标签 ================= */
.tabbar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .nav { display: none; }
  .brand .sub { display: none; }
  .main { padding-bottom: 5rem; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: rgba(2,6,23,.9); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
    padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom));
  }
  .tabbar a { display: grid; justify-items: center; gap: .15rem; padding: .45rem 0; color: var(--text-dim); font-size: .64rem; }
  .tabbar a .ic { font-size: 1.15rem; }
  .tabbar a.active { color: var(--accent-blue); }
  .stat .v { font-size: 1.45rem; }
}
@media (max-width: 480px) {
  .topbar .chip.hide-sm { display: none; }
  .home-btn { padding: .5rem .6rem; }        /* 小屏收窄「返回主页」 */
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
