* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --line: #d5dbe4;
  --ink: #1e2733;
  --muted: #5b6675;
  --brand: #00497f;
  --brand-2: #0066a8;
  --accent: #0e7c5a;
  --warn: #b45309;
  --code-bg: #f4f7fa;
  --shadow: 0 1px 3px rgba(16,40,70,.10);
  --radius: 8px;
}

html { font-size: 16px; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  padding: 8px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.05rem; min-width: 0; }
.topbar .brand .logo { font-size: 1.3rem; }
.topbar .links { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar .links a {
  color: #fff;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: .9rem;
}
.topbar .links a:hover { background: rgba(255,255,255,.26); text-decoration: none; }

/* ---------- Toolstrip ---------- */
.toolstrip {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
}
.navtabs { display: flex; flex-wrap: wrap; gap: 4px; }
.navtabs a {
  padding: 7px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-size: .92rem;
  border: 1px solid transparent;
}
.navtabs a:hover { background: var(--code-bg); text-decoration: none; }
.navtabs a.active { background: var(--brand); color: #fff; }
/* ---------- Grouped drop-down menu bar (Windows-style) ---------- */
.menubar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 2px; }
.menubar .menu-cat { position: relative; }
.menu-btn, .menu-action {
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border-radius: 6px; border: 1px solid transparent;
  color: var(--muted); font-size: .92rem; background: transparent;
}
.menu-action { text-decoration: none; }
.menu-action:hover { background: var(--code-bg); text-decoration: none; }
.menu-action.active { background: var(--brand); color: #fff; }
.menu-btn:hover, .menu-cat:hover .menu-btn, .menu-cat:focus-within .menu-btn { background: var(--code-bg); color: var(--ink); }
.menu-btn .caret { display:inline-block; width:0; height:0; margin-left:3px; border-left:4px solid transparent; border-right:4px solid transparent; border-top:5px solid currentColor; }
.menu-drop {
  display: none; position: absolute; top: 100%; left: 0; z-index: 60;
  min-width: 250px; max-width: 360px; max-height: 72vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(0,0,0,.18); padding: 6px;
}
.menu-cat:hover .menu-drop, .menu-cat:focus-within .menu-drop { display: block; }
.menu-drop .menu-item {
  display: block; padding: 6px 10px; border-radius: 6px; color: var(--ink);
  font-size: .9rem; text-decoration: none;
}
.menu-drop .menu-item:hover { background: var(--code-bg); text-decoration: none; }
.menu-drop .menu-item.active { background: var(--brand); color: #fff; }
@media (max-width: 860px){
  .menubar { flex-wrap: wrap; }
  .menu-drop { position: static; min-width: 0; box-shadow: none; }
}
.controls { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.control-group { display: flex; align-items: center; gap: 6px; font-size: .86rem; color: var(--muted); }
select, button {
  font-family: inherit; font-size: .9rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 6px;
}
select:focus, .field input:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; }

/* ---------- Layout ---------- */
.wrap { width: min(1120px, 100% - 32px); margin: 22px auto; flex: 1; }
h1.page-title { font-size: 1.6rem; margin-bottom: 4px; }
p.page-desc { color: var(--muted); margin-bottom: 20px; max-width: 820px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 {
  font-size: 1.1rem;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--brand);
  display: flex; align-items: center; gap: 8px;
}

.home-card { display: flex; flex-direction: column; gap: 8px; }
.home-card .hc-icon { font-size: 1.9rem; }
.home-card h3 { font-size: 1.1rem; }
.home-card p { color: var(--muted); font-size: .92rem; flex: 1; }
.home-card a.go {
  margin-top: 4px; align-self: flex-start;
  background: var(--brand-2); color: #fff; padding: 6px 12px; border-radius: 6px; font-size: .9rem;
}
.home-card a.go:hover { background: var(--brand); text-decoration: none; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .88rem; margin-bottom: 4px; color: var(--ink); font-weight: 500; }
.field .input-row { display: flex; align-items: center; gap: 8px; }
.fleet-band { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .8rem; color: #fff; }
.fleet-band.b-bat { background: #1e7d3a; }
.fleet-band.b-good { background: #7cb86b; }
.fleet-band.b-typ { background: #d9a441; }
.fleet-band.b-high { background: #c04a3a; }
.field input[type=number], .field input[type=text] {
  width: 100%; max-width: 240px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: .95rem;
}
.field .unit { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.hint { font-size: .8rem; color: var(--muted); }

.actions { display: flex; gap: 10px; margin: 6px 0 4px; flex-wrap: wrap; }
.btn { background: var(--brand-2); color: #fff; border: none; padding: 9px 20px; border-radius: 6px; font-size: .95rem; cursor: pointer; }
.btn:hover { background: var(--brand); }
.btn.secondary { background: #e3e8f0; color: var(--ink); }
.btn.secondary:hover { background: #cfd7e3; }

/* ---------- Results ---------- */
.result { margin-top: 16px; display: none; }
.result.show { display: block; }
.result .row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: 6px; margin-bottom: 6px; align-items: baseline;
}
.result .row:nth-child(odd) { background: var(--code-bg); }
.result .row .k { color: var(--muted); font-size: .9rem; }
.result .row .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.result .row .v .u { font-weight: 400; color: var(--muted); margin-left: 4px; font-size: .85rem; }
.result .big .v { font-size: 1.1rem; color: var(--brand-2); }
.note {
  margin-top: 14px; font-size: .84rem; color: var(--warn);
  background: #fff7ea; border: 1px solid #f3ddb3; padding: 10px 12px; border-radius: 6px;
}

table.ref { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.ref th, table.ref td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; }
table.ref th { background: var(--code-bg); font-weight: 600; }

footer.foot {
  text-align: center; color: var(--muted); font-size: .82rem; padding: 18px;
  border-top: 1px solid var(--line); background: var(--panel);
}
.foot-addr { margin-top: 8px; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.foot-addr a { color: var(--accent, #007acc); text-decoration: none; }
.foot-addr a:hover { text-decoration: underline; }
.fa-sep { color: var(--line); }

/* ---- neck finish standards library ---- */
.lib-detail {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 4px 18px; margin: 10px 0; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.lib-detail .row {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px dashed var(--line); padding: 4px 0; font-size: .86rem;
}
.lib-detail .row:last-child { border-bottom: none; }
.lib-detail .k { color: var(--muted); }
.lib-detail .v { font-weight: 600; text-align: right; color: var(--text); }
table.lib-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .84rem; }
table.lib-table th, table.lib-table td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
table.lib-table th { background: var(--code-bg); font-weight: 600; }
table.lib-table tr:hover td { background: #f3f7fb; }

/* ---- versioned plan bar ---- */
.book-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-top: 14px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.book-bar .plan-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.book-bar .plan-sel { min-width: 170px; padding: 8px 10px; }
.book-bar .bar-sep { width: 1px; height: 24px; background: var(--line); }
.book-bar .btn.danger { background: #fef1f1; color: #b91c1c; border: 1px solid #f3c6c6; }
.book-bar .btn.danger:hover { background: #fbdcdc; }
.book-bar .btn.danger:disabled { opacity: .4; cursor: not-allowed; }

/* ---- material thermal conductivity chart ---- */
.tcchart { width: 100%; height: auto; background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
.tcchart .tg { stroke: #e6ebf2; stroke-width: 1; }
.tcchart .tgx { font-size: 9.5px; fill: #8a95a5; }
.tcchart .taxis { font-size: 10px; fill: #5b6675; text-anchor: middle; }
.tc-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; font-size: .85rem; color: var(--ink); }
.tc-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.tc-legend .sw { width: 18px; height: 4px; border-radius: 2px; }

/* ---- check / warning panel ---- */
.warnings { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 10px; }
.warnings.hide { display: none; }
.warnings .w-warn, .warnings .w-err, .warnings .w-ok {
  display: flex; gap: 6px; align-items: baseline;
  font-size: .82rem; padding: 7px 10px; border-radius: 6px; margin-bottom: 6px;
}
.warnings .w-ok { background: #eef7ef; color: #1a7f37; border: 1px solid #cfe8d3; }
.warnings .w-warn { background: #fff7ea; color: var(--warn); border: 1px solid #f3ddb3; }
.warnings .w-err { background: #fef2f0; color: #b91c1c; border: 1px solid #f5c6c0; }

/* ---- inline SVG charts (heat balance / flue recovery) ---- */
.chartbox { margin-top: 10px; padding: 6px 2px; }
.chartbox svg { display: block; max-width: 100%; height: auto; }
.chartbox .seg { transition: opacity .15s; }

/* ---- multi-level closed-loop linkage chain ---- */
.chain { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin-top: 12px; }
.chain-node { flex: 1 1 130px; min-width: 120px; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; background: var(--card); text-align: center; }
.chain-node .chain-k { font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.chain-node .chain-v { font-size: .95rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.chain-node.han { border-color: var(--brand-2); background: color-mix(in srgb, var(--brand-2) 7%, var(--card)); }
.chain-node.han .chain-k,
.chain-node.han .chain-v { color: var(--brand-2); }
.chain-arrow { align-self: center; color: #aab4c0; font-size: 1.15rem; font-weight: 700; }
