/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --border: #dfe3ea;
  --text: #1f2733;
  --muted: #6b7686;
  --primary: #1a5fb4;
  --primary-hover: #144a8f;
  --ok: #1a7f37;
  --ok-bg: #e8f6ec;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --err: #c33;
  --err-bg: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ===== 顶栏 ===== */
.topbar {
  background: #0f2a4a;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.topbar h1 { font-size: 19px; font-weight: 600; }
.subtitle { font-size: 12px; color: #b9c8dd; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; }
.badge-info { background: #21466e; color: #cfe0f5; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }

/* ===== 布局 ===== */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 18px;
  padding: 18px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel h2 { font-size: 15px; margin-bottom: 14px; color: #0f2a4a; }
.result-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ===== 表单 ===== */
.field-label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #33404f; }
textarea#nl-input {
  width: 100%; resize: vertical; min-height: 76px;
  padding: 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; line-height: 1.6; outline: none;
}
textarea#nl-input:focus { border-color: var(--primary); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select {
  width: 100%; padding: 7px 8px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; outline: none; background: #fff;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.range { display: flex; align-items: center; gap: 6px; }
.range input { flex: 1; min-width: 0; }
.range span { color: var(--muted); }

.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }

/* ===== 按钮 ===== */
.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  font-size: 13px; cursor: pointer; transition: background .12s, opacity .12s;
}
.btn-primary { background: var(--primary); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }
.btn-lg { padding: 10px 18px; font-size: 14px; }

/* ===== 结果区 ===== */
.result-empty { text-align: center; padding: 70px 20px; color: var(--muted); line-height: 1.9; }
.result-empty-icon { font-size: 46px; }

.summary { background: #f7f9fc; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-size: 13px; line-height: 1.8; margin-bottom: 14px; }
.summary b { color: var(--primary); }

.recommend { border: 1px solid #b9d2f0; background: #f0f6ff; border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.recommend-title { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }

.section-title { font-size: 14px; margin: 18px 0 10px; color: #0f2a4a; }

.candidate { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.candidate-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  background: #fff; flex-wrap: wrap;
}
.candidate-head:hover { background: #f8fafd; }
.cand-rank { font-size: 13px; font-weight: 700; color: var(--primary); min-width: 30px; }
.cand-code { font-size: 16px; font-weight: 700; }
.cand-spec { font-size: 12px; color: var(--muted); }
.cand-stats { display: flex; gap: 16px; margin-left: auto; font-size: 12px; flex-wrap: wrap; }
.cand-stats .kv b { display: block; font-size: 13px; }
.cand-stats .kv { text-align: right; color: var(--muted); }
.chevron { color: var(--muted); transition: transform .15s; }
.candidate.open .chevron { transform: rotate(90deg); }

.candidate-body { display: none; border-top: 1px solid var(--border); padding: 14px; background: #fbfcfe; }
.candidate.open .candidate-body { display: block; }

.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.calc-item { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.calc-item .k { font-size: 12px; color: var(--muted); }
.calc-item .v { font-size: 15px; font-weight: 600; margin-top: 3px; }

.formula { background: #f1f4f8; border-radius: 8px; padding: 10px 12px; font-size: 12px; color: #33404f; line-height: 1.7; margin: 8px 0; }
.reasons { margin-top: 10px; }
.reasons li { font-size: 12px; color: #33404f; margin-left: 18px; line-height: 1.8; }
.reason-ok { color: var(--ok); }
.reason-warn { color: var(--warn); }

.svg-wrap { text-align: center; margin: 8px 0; }
.svg-wrap svg { max-width: 100%; height: auto; }
.svg-cap { font-size: 11px; color: var(--muted); }

.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.qty-row input { width: 64px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; }

/* ===== 页脚 ===== */
.footer { padding: 14px 24px 20px; font-size: 11px; color: var(--muted); line-height: 1.8; text-align: center; }

/* ===== 打印 ===== */
@media print {
  .topbar, .input-panel, .result-actions, .qty-row, .btn, .footer, .result-empty { display: none !important; }
  .layout { display: block; padding: 0; }
  .panel { box-shadow: none; border: none; padding: 0; }
  .candidate { break-inside: avoid; }
  .candidate-body { display: block !important; }
  body { background: #fff; }
}
/* ===== 品类标签 ===== */
.cat-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cat-tab {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  transition: all .12s;
}
.cat-tab:hover { border-color: var(--primary); color: var(--primary); }
.cat-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }
/* ===== 侧边栏（11 大类导航） ===== */
.app-body { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 268px; min-width: 220px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.sidebar-head h2 { font-size: 15px; margin-bottom: 8px; color: #0f2a4a; }
.sidebar-head input[type="search"] {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; outline: none;
}
.sidebar-head input[type="search"]:focus { border-color: var(--primary); }
.side-nav { flex: 1; overflow-y: auto; padding: 6px 8px 16px; }
.nav-group { margin-bottom: 4px; }
.nav-group-head {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: #0f2a4a; background: #f4f7fb; cursor: default;
}
.nav-icon { font-size: 14px; }
.nav-count { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 400; }
.nav-sub { padding: 2px 0 6px 14px; }
.nav-sub-title { font-size: 11px; color: var(--muted); padding: 6px 8px 2px; }
.nav-part {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  padding: 6px 10px; font-size: 13px; color: var(--text); border-radius: 6px; cursor: pointer;
}
.nav-part:hover { background: #eef3fa; color: var(--primary); }
.nav-part.active { background: var(--active-bg); color: var(--primary); font-weight: 600; }
.nav-part.disabled { color: var(--muted); cursor: default; }
.part-title { font-size: 13px; color: var(--primary); font-weight: 600; }
@media (max-width: 980px) {
  .app-body { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 260px; }
  .layout { grid-template-columns: 1fr; }
}