:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #5b6675;
  --line: #e2e8f0;
  --brand: #1659c4;
  --brand-d: #0f3f93;
  --accent: #0a8f6b;
  --warn: #c2760a;
  --ok: #178a4c;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    "Noto Sans CJK KR", "Noto Sans CJK JP", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.02rem;
}
.brand-link .logo { color: var(--brand); font-size: 1.25rem; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f0f4fa; border-color: #cdd8e6; }
.btn-home { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-home:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn-email { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-email:hover { filter: brightness(.94); }
.lang-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.lang-label { white-space: nowrap; }
#langSelect {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: .9rem;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.container { max-width: 980px; margin: 0 auto; padding: 22px 18px 40px; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--brand); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
h1.page-title { font-size: 1.5rem; margin: 4px 0 4px; }
.page-desc { color: var(--muted); margin: 0 0 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card h2 { font-size: 1.1rem; margin: 0 0 12px; }
.card h3 { font-size: .95rem; margin: 16px 0 8px; color: var(--brand-d); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Home grid ---------- */
.home-intro { color: var(--muted); margin: 0 0 20px; max-width: 720px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.calc-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.calc-card:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 6px 18px rgba(22, 89, 196, .14); }
.calc-card .icon { font-size: 1.5rem; }
.calc-card h3 { margin: 8px 0 6px; color: var(--brand); font-size: 1.05rem; text-transform: none; letter-spacing: 0; }
.calc-card p { margin: 0; color: var(--muted); font-size: .9rem; }

/* ---------- Forms ---------- */
.row { display: flex; flex-wrap: wrap; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; }
.field label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.field .unit { color: #95a1b1; font-weight: 400; }
.field input, .field select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .95rem;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,89,196,.15); }
.method-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.method-tab {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: .88rem; color: var(--muted);
}
.method-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-d); }
.btn-ghost { background: #fff; }

/* ---------- Result ---------- */
.result .out-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.out-item { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.out-item .out-label { font-size: .8rem; color: var(--muted); }
.out-item .out-value { font-size: 1.35rem; font-weight: 700; color: var(--brand-d); margin-top: 2px; }
.out-item .out-value small { font-size: .8rem; color: var(--muted); font-weight: 500; margin-left: 4px; }
.result.hidden { display: none; }

.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--ink); font-size: .95rem; }
.note { color: var(--muted); font-size: .9rem; background: #fff8ec; border: 1px solid #f3e2c0; border-radius: 8px; padding: 10px 12px; }

/* ---------- Badges (servo checks) ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; font-size: .9rem; border: 1px solid var(--line); background: #fff; }
.badge .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.badge.warn .dot { background: var(--warn); }
.badge.warn { border-color: #f0d49a; background: #fff8ec; }

/* ---------- Recommendation (sample library) ---------- */
.rec-wrap { margin-top: 6px; }
.rec-h {
  font-size: 1.05rem; margin: 0 0 10px; color: var(--brand-d);
  display: flex; align-items: center; gap: 8px;
}
.rec-h::before { content: "🔧"; font-size: 1.1rem; }
.rec-none {
  color: var(--muted); background: #f7f9fc; border: 1px dashed var(--line);
  border-radius: 10px; padding: 14px; margin: 0;
}
.rec-req { font-size: .85rem; color: var(--muted); margin: 0 0 12px; }
.rec-req::before { content: "▸ "; color: var(--brand); }

.rec-item {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 12px; background: #fff;
}
.rec-item.rec-best {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 89, 196, .10);
  background: linear-gradient(180deg, #f3f8ff, #ffffff);
}
.rec-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.rec-brand { font-weight: 700; color: var(--ink); }
.rec-series { font-size: .85rem; color: var(--muted); }
.rec-best-badge {
  margin-left: auto; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  color: #fff; background: var(--brand); padding: 3px 8px;
  border-radius: 999px; text-transform: uppercase;
}
.rec-model {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: .9rem;
  color: var(--brand-d); margin: 4px 0 8px;
}
.rec-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.rec-table td { padding: 3px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.rec-table tr:first-child td { border-top: none; }
.rec-k { color: var(--muted); white-space: nowrap; width: 1%; padding-right: 14px; }
.rec-v { color: var(--ink); font-weight: 600; }
.rec-actions { margin-top: 12px; }
.rec-print {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: .88rem;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  transition: background .15s, border-color .15s;
}
.rec-print:hover { background: #f0f4fa; border-color: #cdd8e6; }

.rec-cmp {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px; cursor: pointer; font-size: .82rem;
  background: #fff; color: var(--brand-d); border: 1px solid var(--brand);
  transition: background .15s, color .15s;
}
.rec-cmp:hover { background: #eef4ff; }
.rec-cmp .cmp-ico { font-weight: 700; }
.rec-cmp.is-on { background: var(--brand); color: #fff; border-color: var(--brand); }

.cmp-bar {
  position: fixed; right: 16px; bottom: 16px; z-index: 60; display: none;
  align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, .16); padding: 8px 10px 8px 14px;
}
.cmp-bar .cmp-link { text-decoration: none; color: var(--brand-d); font-weight: 600; font-size: .9rem; }
.cmp-bar .cmp-count { color: var(--brand); }
.cmp-bar .cmp-clear { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: .82rem; }
.cmp-bar .cmp-clear:hover { background: #f0f4fa; }

/* ---------- Sample library page ---------- */
.lib-count { font-size: .9rem; color: var(--muted); margin: 4px 0 14px; }
.lib-count #libCount { font-weight: 700; color: var(--brand-d); }
.lib-cat { margin-bottom: 20px; }
.lib-cat-h {
  font-size: 1.05rem; color: var(--brand-d); margin: 0 0 10px;
  border-left: 4px solid var(--brand); padding-left: 10px;
}
.lib-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  margin-bottom: 12px; background: #fff;
}
.lib-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.lib-specs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.lib-spec {
  font-size: .82rem; background: #f2f6fc; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; color: var(--ink);
}
.lib-spec b { color: var(--muted); font-weight: 600; margin-right: 4px; }
.lib-notes { font-size: .8rem; color: var(--muted); margin-top: 8px; font-style: italic; }

/* ---------- Compare page ---------- */
.cmp-empty { color: var(--muted); background: #f7f9fc; border: 1px dashed var(--line); border-radius: 10px; padding: 18px; margin: 0; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.cmp-table th, .cmp-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cmp-table th { color: var(--muted); font-weight: 600; background: #f7f9fc; }
.cmp-cat-tag { display: inline-block; font-size: .72rem; font-weight: 700; color: #fff; background: var(--accent); padding: 2px 8px; border-radius: 999px; }
.cmp-specs { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-spec { font-size: .8rem; background: #f2f6fc; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; }
.cmp-spec b { color: var(--muted); font-weight: 600; margin-right: 4px; }
.cmp-remove { color: var(--warn); background: #fff; border: 1px solid #f0d49a; border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: .82rem; }
.cmp-remove:hover { background: #fff8ec; }
.cmp-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.cmp-add-card { margin: 0 0 16px; padding: 14px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px; }
.cmp-add-card h3 { margin: 0 0 10px; font-size: .95rem; color: var(--text); }
.cmp-lib-sel { width: 100%; }
.cmp-view-bar { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; font-size: .9rem; }
.cmp-view-bar label { font-weight: 600; color: var(--text); }
.cmp-view-bar .cmp-lib-sel { width: auto; min-width: 220px; }
.cmp-cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.cmp-cat-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.cmp-cat-head { margin: 0 0 8px; font-size: .95rem; color: var(--brand-d); }
.cmp-cat-count { color: var(--muted); font-weight: 500; font-size: .82rem; }
.cmp-table-mini { font-size: .82rem; }
.cmp-table-mini th, .cmp-table-mini td { padding: 6px 8px; }
.cmp-hl-legend { margin: 0 0 8px; font-size: .74rem; color: var(--muted); font-style: italic; }
.cmp-hl-legend .hl-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 3px; vertical-align: middle; }
.cmp-hl-legend .hl-max { background: #d6342b; }
.cmp-hl-legend .hl-min { background: #1aa260; }
.cmp-hl-legend .hl-range { background: #2f7fd6; }
.cmp-best { background: #fde8e6; color: #b30000; font-weight: 700; border-radius: 4px; }
.cmp-worst { background: #e6f4ec; color: #006622; font-weight: 700; border-radius: 4px; }
.cmp-range { background: #e7f0fd; color: #1f5fb0; font-weight: 600; border-radius: 4px; }

/* ---------- Compare — highlight conclusions ---------- */
.cmp-conclusions { margin-top: 18px; }
.cmp-concl-title { font-size: 1.05rem; color: var(--brand-d); margin: 0 0 12px; border-left: 4px solid var(--brand); padding-left: 10px; }
.cmp-concl-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.cmp-concl-head { margin: 0 0 6px; font-size: .95rem; color: var(--brand-d); }
.cmp-concl-line { font-size: .85rem; color: var(--ink); padding: 2px 0; border-top: 1px solid var(--line); }
.cmp-concl-line:first-of-type { border-top: none; }
.cmp-concl-line b { color: var(--muted); font-weight: 600; margin-right: 4px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 18px; text-align: center; color: var(--muted); font-size: .82rem; }
.site-footer .footer-text { margin: 0 0 4px; font-weight: 600; color: var(--ink); }
.site-footer .footer-disclaimer { margin: 0; max-width: 760px; margin: 0 auto; }

/* ---------- Print / Export ---------- */
.hidden { display: none !important; }
.cmp-report-meta { display: none; font-size: .82rem; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; margin: 2px 0 12px; cursor: pointer; }
.chk input { width: 16px; height: 16px; }

/* Efficiency curve (part-load) mini bar chart */
.eff-curve { display: flex; align-items: flex-end; gap: 12px; height: 78px; margin: 2px 0; }
.eff-bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: 44px; }
.eff-bar-fill { width: 100%; background: linear-gradient(180deg, var(--brand), var(--brand-d)); border-radius: 4px 4px 0 0; min-height: 2px; }
.eff-bar-val { font-size: .72rem; color: var(--ink); margin-top: 3px; font-weight: 600; }
.eff-bar-load { font-size: .68rem; color: var(--muted); }

/* ---------- Standards & Formulas table ---------- */
.std-scroll { overflow-x: auto; }
.std-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 720px; }
.std-table th, .std-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.std-table thead th { color: var(--muted); font-weight: 600; background: #f7f9fc; position: sticky; top: 0; }
.std-table tbody tr:hover { background: #fafcff; }
.std-mod { font-weight: 600; color: var(--ink); white-space: nowrap; }
.std-std { color: var(--brand-d); font-size: .86rem; }
.std-formula { font-size: .85rem; max-width: 320px; line-height: 1.5; }
.std-note { color: var(--muted); font-size: .85rem; max-width: 320px; line-height: 1.5; }
.std-disc { margin-top: 14px; font-size: .82rem; color: var(--muted); }

/* ---------- IE efficiency payback table ---------- */
.ie-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 6px; }
.ie-table th, .ie-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.ie-table th:first-child, .ie-table td:first-child { text-align: left; font-weight: 600; color: var(--ink); white-space: nowrap; }
.ie-table thead th { color: var(--muted); font-weight: 600; background: #f7f9fc; }
.ie-table tbody tr:nth-child(even) { background: #fafcff; }
.ie-savings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.ie-sav-block h3 { font-size: .95rem; margin: 0 0 8px; color: var(--brand-d); }
.ie-cmp-shortcut { margin-top: 18px; }
.ie-cmp-shortcut .btn[disabled] { opacity: .5; cursor: not-allowed; }
@media (max-width: 640px) { .ie-savings { grid-template-columns: 1fr; } }

@media print {
  body { background: #fff; }
  .site-header, .site-footer, .actions, .breadcrumb, .lang-wrap, .rec-actions,
  .method-tabs, .lib-controls, .lib-count, .lib-cat, .cmp-bar, .cmp-actions, .cmp-remove, .cmp-add-card, .cmp-view-bar, .ie-cmp-shortcut { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .rec-item { break-inside: avoid; }
  .page-desc { display: none; }
  .cmp-report-meta { display: block !important; }
  .cmp-table th, .cmp-table td { border: 1px solid #bbb; }
  .std-table th, .std-table td { border: 1px solid #bbb; }
  .ie-table th, .ie-table td { border: 1px solid #bbb; }
  .std-disc { display: block !important; }
}

@media (max-width: 560px) {
  .site-header { padding: 8px 12px; }
  .container { padding: 16px 12px 32px; }
  .header-actions { width: 100%; justify-content: flex-end; }
}
