/* HVAC Hardware Tools - shared stylesheet */
:root {
  --primary: #1f5f8b;
  --primary-dark: #174a6d;
  --primary-light: #e8f1f8;
  --accent: #e0862d;
  --bg: #f4f7fa;
  --card: #ffffff;
  --text: #22303c;
  --text-soft: #5b6b7a;
  --border: #d8e0e8;
  --line: #edf1f5;
  --ok: #2e9e5b;
  --warn: #d9534f;
  --radius: 10px;
  --shadow: 0 6px 18px rgba(31,95,139,.10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans", "Yu Gothic UI", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.topbar {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  color: #fff;
}
.topbar-inner {
  max-width: 1520px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand .logo { width: 34px; height: 34px; border-radius: 8px; background: #fff; display:grid; place-items:center; color: var(--primary); font-weight: 800; font-size: 16px; }
.brand .title { font-weight: 700; font-size: 16px; line-height: 1.1; }
.brand .subtitle { font-size: 11px; opacity: .85; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; margin-left: auto; }
.btn-top {
  background: rgba(255,255,255,.14); color:#fff;
  border: 1px solid rgba(255,255,255,.4); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; text-decoration: none;
  display:inline-flex; align-items:center; gap:6px; white-space: nowrap;
}
.btn-top:hover { background: rgba(255,255,255,.26); text-decoration: none; }
.lang-select {
  background: #fff; color: var(--text); border: none; border-radius: 8px;
  padding: 6px 8px; font-size: 13px; font-weight:600; cursor: pointer;
}

/* ---------- Nav ---------- */
.navbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.nav-inner {
  max-width: 1520px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; overflow: visible;
}
.nav-inner a {
  color: var(--text); padding: 12px 14px; font-size: 14px; font-weight: 600;
  white-space: nowrap; border-bottom: 3px solid transparent;
}
.nav-inner a:hover { color: var(--primary); text-decoration: none; border-bottom-color: var(--primary-light); }
.nav-inner a.active { color: var(--primary); border-bottom-color: var(--primary); }
.nav-group {
  align-self: stretch; display: inline-flex; align-items: center;
  padding: 0 10px; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  color: var(--text-soft); text-transform: uppercase; white-space: nowrap;
}
.nav-group::before, .nav-group::after { content: ""; width: 1px; height: 14px; margin: 0 8px; background: var(--border); }

/* Windows-style dropdown menus */
.menu { position: relative; display: inline-flex; align-items: center; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  color: var(--text); padding: 12px 12px; font-size: 14px; font-weight: 600;
  white-space: nowrap; border-bottom: 3px solid transparent;
  font-family: inherit; text-decoration: none;
}
.menu-btn:hover { color: var(--primary); border-bottom-color: var(--primary-light); text-decoration: none; }
.menu-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.menu-btn .caret { font-size: 11px; opacity: .7; transition: transform .12s ease; }
.menu:hover > .menu-btn .caret { transform: rotate(180deg); }
.menu-drop {
  position: absolute; left: 0; top: 100%; z-index: 100;
  min-width: 220px; padding: 6px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31,95,139,.16);
  display: none; flex-direction: column; gap: 1px;
}
.menu:hover > .menu-drop, .menu:focus-within > .menu-drop, .menu.open > .menu-drop { display: flex; }
.menu-drop a {
  display: block; padding: 8px 12px; border: none; border-radius: 6px;
  color: var(--text); font-size: 14px; font-weight: 500;
  white-space: nowrap; line-height: 1.4;
}
.menu-drop a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.menu-drop a.active { color: var(--primary); font-weight: 700; }

/* ---------- Layout ---------- */
.container { max-width: 1520px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head h1 { font-size: 26px; margin: 4px 0 4px; color: var(--primary-dark); }
.page-head p { color: var(--text-soft); margin: 0 0 6px; }
.crumbs { font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-top: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; color: var(--primary-dark); }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card h4 { margin: 16px 0 6px; font-size: 13.5px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.card h4:first-child { margin-top: 4px; }
.sec-head { font-size: 20px; font-weight: 800; color: var(--primary-dark); margin: 30px 0 4px; }

.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(6, 1fr); }
.grid.cols2 { grid-template-columns: 1fr 1fr; }
.grid.cols3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1400px){ .grid.cards { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1120px){ .grid.cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px){ .grid.cards { grid-template-columns: repeat(2, 1fr); } .grid.cols2,.grid.cols3 { grid-template-columns: 1fr; } }
@media (max-width: 560px){ .grid.cards { grid-template-columns: 1fr; } }

/* ---------- Cards on home ---------- */
.toolcard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
  transition: transform .12s ease, box-shadow .12s ease; text-decoration: none; color: var(--text);
}
.toolcard:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(31,95,139,.16); text-decoration: none; }
.toolcard .ico { font-size: 26px; }
.toolcard .t { font-weight: 700; font-size: 16px; color: var(--primary-dark); }
.toolcard .d { font-size: 13px; color: var(--text-soft); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.field { flex: 1 1 160px; min-width: 140px; }
input[type=number], input[type=text], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text); background: #fff; font-family: var(--font);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.seg {
  display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.seg button {
  border: none; background: #fff; padding: 7px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; color: var(--text-soft);
}
.seg button.active { background: var(--primary); color: #fff; }
.btn {
  border: none; border-radius: 8px; padding: 9px 18px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: var(--font);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }

/* ---------- Result ---------- */
.result-box {
  border: 2px solid var(--primary); background: var(--primary-light);
  border-radius: var(--radius); padding: 16px; margin-top: 10px;
}
.result-box .big { font-size: 26px; font-weight: 800; color: var(--primary-dark); }
.result-box .rows { margin-top: 8px; font-size: 13px; color: var(--text-soft); }
.formula { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12px; color: var(--text-soft); background: var(--line); padding: 8px 10px; border-radius: 8px; margin-top: 8px; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th {
  background: var(--primary); color: #fff; text-align: left; padding: 8px 10px;
  font-weight: 700; white-space: nowrap; position: sticky; top: 0;
}
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:nth-child(even) { background: #f5f9fd; }
.tbl tbody tr:hover { background: #eef5fb; }
.tbl td.num, .tbl th.num { text-align: right; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar .grow { flex: 1 1 220px; }

.pill { display:inline-block; background: var(--primary-light); color: var(--primary); border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight:600; }
.note { font-size: 12px; color: var(--text-soft); margin-top: 10px; }

/* footer */
.footer {
  background: var(--primary-dark); color: #cfdfec; margin-top: 30px;
}
.footer-inner { max-width: 1240px; margin: 0 auto; padding: 22px 16px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.footer a { color: #fff; }
.sec-title { font-size: 14px; font-weight: 700; color:#fff; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--text-soft); }
.mt { margin-top: 12px; }
tr.semi td { border-top: 2px solid var(--primary); font-weight: 700; }

/* ---------- Materials grid (pipedata.html) ---------- */
.mats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.mat-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.mat-title { background: var(--primary-light); color: var(--primary-dark); font-weight: 700; font-size: 13px; padding: 8px 10px; }
.mat-card .tbl { margin: 0; border: none; }
.mat-card .tbl th { position: static; padding: 5px 10px; font-size: 12px; }
.mat-card .tbl td { padding: 5px 10px; font-size: 12px; }

/* ---------- Dynamic chart (cmchart.html) ---------- */
.chart-bars { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { width: 150px; min-width: 110px; text-align: right; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; background: var(--line); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary-light), var(--primary)); border-radius: 6px; transition: width .35s ease; }
.bar-val { width: 64px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-soft); white-space: nowrap; }
tr.total-row td { border-top: 2px solid var(--primary); font-weight: 700; }
@media (max-width: 560px) {
  .bar-row { flex-wrap: wrap; }
  .bar-label { width: 100%; text-align: left; }
  .bar-val { text-align: left; }
}