/* ============ ASME B31.3 Calculator — shared styles ============ */
:root {
  --primary: #0d4f8b;
  --primary-dark: #0a3c6b;
  --accent: #e2a825;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e2e6ec;
  --ok: #1a7f37;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(13, 79, 139, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top action bar (返回主页 / 发送邮件) ---------- */
.topbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 20px;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
}
.topbar .brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.topbar .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-outline {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .18s;
  cursor: pointer;
  font-family: inherit;
}
.btn-outline:hover { background: rgba(255,255,255,0.28); }

.language-switcher { position: relative; }
.language-switcher select {
  appearance: none;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  border-radius: 8px;
  padding: 7px 28px 7px 12px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.language-switcher select option { color: #1f2933; background: #fff; }

/* ---------- Nav ---------- */
.nav {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 7px 13px;
  border-radius: 8px;
}
.nav a:hover { background: #eaf2fb; }
.nav a.active { background: var(--primary); color: #fff; }

/* ---------- Layout ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
}

h1 { font-size: 26px; margin: 0 0 6px; color: var(--primary-dark); }
h2 { font-size: 19px; margin: 0 0 12px; color: var(--primary-dark); }
.subtitle { color: var(--muted); margin: 0 0 18px; font-size: 14.5px; }

.lead { font-size: 15px; margin: 0 0 16px; }

/* ---------- Tool cards (home) ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; margin-top: 8px; }
.tool-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: #fff;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(13,79,139,.14); border-color: var(--primary); }
.tool-card .icon { font-size: 30px; }
.tool-card h3 { margin: 0; font-size: 17px; color: var(--primary-dark); }
.tool-card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.tool-card .go { color: var(--primary); font-weight: 600; font-size: 13.5px; margin-top: auto; }

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: #334155; }
.field label .unit-hint { font-weight: 400; color: var(--muted); }
.field input[type=text], .field input[type=number], .field select {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  width: 100%;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,79,139,.12);
}

.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  font-family: inherit;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.row-btns { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.btn {
  border: none;
  border-radius: 9px;
  padding: 10px 20px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #eef2f7; color: #334155; }
.btn-ghost:hover { background: #e2e8f0; }

/* ---------- Results ---------- */
.result-panel { background: linear-gradient(135deg, #0b4d87, #0a3c6b); color: #fff; border-radius: var(--radius); padding: 22px; display: none; }
.result-panel.show { display: block; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 6px; }
.result-item { background: rgba(255,255,255,.1); border-radius: 9px; padding: 12px 14px; }
.result-item .lbl { font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .4px; }
.result-item .val { font-size: 22px; font-weight: 700; margin-top: 3px; }
.result-item .sub { font-size: 12px; opacity: .75; }

.status-msg { margin-top: 14px; font-size: 13.5px; border-radius: 8px; padding: 10px 13px; display: none; }
.status-msg.show { display: block; }
.status-ok { background: #e7f6ec; color: var(--ok); border: 1px solid #bfe8cc; }
.status-warn { background: #fdf3e2; color: var(--warn); border: 1px solid #f2d9a8; }
.status-danger { background: #fdeaea; color: var(--danger); border: 1px solid #f3c0c0; }

/* ---------- Formula & reference ---------- */
.formula { background: #f8fafc; border: 1px dashed var(--line); border-radius: 9px; padding: 14px 16px; font-size: 14.5px; margin-top: 16px; }
.formula .frac { font-size: 18px; font-weight: 600; }
.muted-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 12px; }

table.ref-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
table.ref-table th, table.ref-table td { border: 1px solid var(--line); padding: 7px 9px; text-align: center; }
table.ref-table th { background: #eef2f7; font-weight: 600; }
table.ref-table td:first-child { text-align: left; }
.table-wrap { overflow-x: auto; }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--line); padding: 18px 20px; text-align: center; color: var(--muted); font-size: 12.5px; background: #fff; }
footer a { color: var(--primary); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .container { padding: 16px 14px 40px; }
  .card { padding: 18px; }
  h1 { font-size: 22px; }
  .formula .frac { font-size: 16px; }
}