/* ============================================================
   ASME VIII-1 压力容器设计助手 · 共享样式
   ============================================================ */
:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #d8e0ea;
  --border-strong: #b9c6d6;
  --text: #1c2b3a;
  --text-2: #5a6b7f;
  --text-3: #8a9ab0;
  --primary: #16456f;
  --primary-2: #1f5e94;
  --accent: #2e86c1;
  --ok: #1e8e5a;
  --ok-bg: #e6f6ee;
  --warn: #b7791f;
  --warn-bg: #fdf3e3;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --info-bg: #e8f1fb;
  --code-bg: #f0f4f9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(22, 46, 77, .08), 0 4px 14px rgba(22, 46, 77, .06);
  --shadow-lg: 0 6px 24px rgba(22, 46, 77, .14);
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --mono: "Consolas", "Cascadia Mono", "SF Mono", "Courier New", monospace;
  --math: "Cambria Math", "STIX Two Math", "Times New Roman", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(100deg, #0e2a44 0%, #16456f 55%, #1f5e94 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(10, 30, 55, .25);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 14px; min-height: 58px; position: relative;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; flex-shrink: 0; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #ffd97a;
}
.brand .brand-name { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.brand .brand-sub { font-size: 11px; opacity: .75; margin-top: -2px; }

/* Windows 风格菜单栏：顶部分类 + 下拉面板 */
.menu-bar { display: flex; align-items: center; gap: 2px; min-width: 0; }
.menu-link, .menu-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: transparent; color: rgba(255,255,255,.9);
  padding: 6px 11px; border-radius: 7px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
}
.menu-link:hover, .menu-btn:hover, .menu-btn[aria-expanded="true"] { background: rgba(255,255,255,.14); color: #fff; }
.menu-link.active { background: rgba(255,255,255,.2); color: #fff; }
.menu-btn .caret { font-size: 9px; opacity: .8; transition: transform .15s; }
.menu-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }

.menu-item { position: relative; }
.dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 250px;
  background: #fff; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px; box-shadow: 0 12px 28px rgba(10, 30, 55, .22); z-index: 70;
}
.menu-item.open .dropdown { display: block; }
.dropdown a {
  display: block; padding: 8px 12px; border-radius: 6px;
  color: var(--text); font-size: 13.5px; text-decoration: none; white-space: nowrap;
}
.dropdown a:hover { background: var(--surface-2); color: var(--primary); }
.dropdown a.active { background: var(--info-bg); color: var(--primary); font-weight: 600; }

.menu-toggle { display: none; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.lang-switch { display: flex; background: rgba(255,255,255,.12); border-radius: 8px; padding: 3px; }
.lang-switch button {
  border: 0; background: transparent; color: rgba(255,255,255,.75);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12.5px; font-family: inherit;
}
.lang-switch button.active { background: #fff; color: var(--primary); font-weight: 700; }

.lang-sel {
  background: rgba(255,255,255,.14); color: #fff;
  border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
  padding: 5px 8px; font-size: 12.5px; font-family: inherit; cursor: pointer;
  max-width: 150px;
}
.lang-sel option { color: var(--text); background: #fff; }

/* 顶栏工具链接（返回主页 / 发送邮件） */
.tb-link {
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,.12); color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.18); border-radius: 8px;
  padding: 5px 10px; font-size: 12.5px; font-weight: 600;
  font-family: inherit; text-decoration: none; white-space: nowrap;
}
.tb-link:hover { background: rgba(255,255,255,.22); color: #fff; }

/* ---------- 布局 ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 26px 20px 60px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 6px; font-size: 26px; color: var(--primary); letter-spacing: .2px; }
.page-head .sub { color: var(--text-2); font-size: 14.5px; max-width: 900px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card h2 { margin: 0 0 14px; font-size: 17px; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.card h2 .num {
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--info-bg); border: 1px solid #c4ddf3;
  padding: 2px 8px; border-radius: 20px; letter-spacing: .5px;
}
.card h3 { margin: 18px 0 10px; font-size: 15px; color: var(--text); border-left: 3px solid var(--accent); padding-left: 10px; }
.card p { margin: 8px 0; color: var(--text-2); }
.card p b { color: var(--text); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; font-weight: 600; }
.field label .req { color: var(--danger); }
.input-row { display: flex; align-items: stretch; gap: 8px; }
.input-row .unit {
  min-width: 52px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px; color: var(--text-2); font-weight: 600;
}
.input-row input, .input-row select, .field select, .field input[type="text"], .field input[type="number"], .search-box input {
  flex: 1; width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14.5px; font-family: var(--mono); color: var(--text);
  background: #fff; transition: border .15s, box-shadow .15s;
}
.input-row input:focus, .field select:focus, .search-box input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 134, 193, .18);
}
.field select { font-family: var(--font); }
select { cursor: pointer; }
input[type="number"]::-webkit-inner-spin-button { opacity: .4; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.hint b { color: var(--text-2); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; cursor: pointer; border-radius: 8px;
  padding: 10px 20px; font-size: 14px; font-weight: 600; font-family: inherit;
  transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); transform: translateY(-1px); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #2573ab; transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--primary); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- 公式展示 ---------- */
.formula {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-family: var(--math); font-size: 16px; color: var(--text);
  overflow-x: auto; white-space: nowrap;
}
.formula .var { font-style: italic; }
.formula .frac { display: inline-flex; flex-direction: column; text-align: center; vertical-align: middle; margin: 0 3px; }
.formula .frac .num { border-bottom: 1.5px solid var(--text); padding: 0 6px 2px; }
.formula .frac .den { padding: 2px 6px 0; }
.formula .sqrt { display: inline-flex; align-items: center; }
.formula .sqrt::before { content: "√"; font-size: 1.25em; margin-right: 2px; }
.formula .rad { border-top: 1.5px solid var(--text); padding-top: 3px; }
.formula .note { display: block; font-family: var(--font); font-size: 12px; color: var(--text-3); margin-top: 8px; white-space: normal; }
.formula .op { margin: 0 4px; color: var(--text-2); }

/* ---------- 结果 ---------- */
.results { display: none; margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.results.show { display: block; }
.result-head {
  background: var(--surface-2); padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; color: var(--primary); font-size: 15px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.result-body { padding: 16px 18px; background: #fff; }
.result-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.result-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.result-table td:first-child { color: var(--text-2); width: 46%; }
.result-table tr:last-child td { border-bottom: 0; }
.result-table .val { font-family: var(--mono); font-weight: 700; color: var(--text); }
.result-table .val.em { color: var(--primary); font-size: 1.05em; }

.verdict { margin-top: 14px; padding: 12px 16px; border-radius: 8px; font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 10px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe5d1; }
.verdict.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #ecd9ae; }
.verdict.fail { background: var(--danger-bg); color: var(--danger); border: 1px solid #f0c4bd; }
.verdict .icon { font-size: 18px; }

/* ---------- 计算过程表格（附录2 / UG-44） ---------- */
table.rst { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.rst td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.rst tr:last-child td { border-bottom: 0; }
table.rst td:first-child { color: var(--text-2); width: 55%; }
table.rst td.big { font-family: var(--mono); font-weight: 700; color: var(--primary); font-size: 1.05em; }
table.rst tr.sec td { background: var(--surface-2); color: var(--primary); font-weight: 700; font-size: 13px; letter-spacing: .3px; border-bottom: 1px solid var(--border); }
table.rst tr.ok td:last-child { color: var(--ok); }
table.rst tr.bad td:last-child { color: var(--danger); }
table.rst td .mk { font-weight: 700; }
table.rst tr.ok td .mk { color: var(--ok); }
table.rst tr.bad td .mk { color: var(--danger); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 480px; }
table.tbl th {
  background: var(--primary); color: #fff; text-align: left;
  padding: 9px 12px; font-weight: 600; font-size: 13px; white-space: nowrap;
}
table.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tbl tbody tr:nth-child(even) { background: var(--surface-2); }
table.tbl tbody tr:hover { background: var(--info-bg); }
table.tbl .mono { font-family: var(--mono); }
table.tbl .nowrap { white-space: nowrap; }
.tbl-note { font-size: 12px; color: var(--text-3); margin-top: 8px; }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge.blue { background: var(--info-bg); color: var(--primary-2); border: 1px solid #c4ddf3; }
.badge.green { background: var(--ok-bg); color: var(--ok); }
.badge.amber { background: var(--warn-bg); color: var(--warn); }
.badge.red { background: var(--danger-bg); color: var(--danger); }

/* ---------- 卡片网格（首页） ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-top: 8px; }
.feature-card {
  display: block; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: .18s; position: relative; overflow: hidden;
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.feature-card .fc-tag {
  position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 700;
  color: var(--accent); background: var(--info-bg); padding: 2px 8px; border-radius: 20px;
}
.feature-card .fc-icon { font-size: 24px; margin-bottom: 8px; display: block; }
.feature-card h3 { margin: 0 0 6px; font-size: 15.5px; color: var(--primary); }
.feature-card p { margin: 0; font-size: 13px; color: var(--text-2); }
.feature-card .fc-arrow { position: absolute; bottom: 10px; right: 14px; color: var(--text-3); font-size: 18px; }

/* ---------- 提示框 ---------- */
.callout { border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13.5px; margin: 12px 0; border: 1px solid; display: flex; gap: 10px; }
.callout .co-icon { font-size: 16px; }
.callout.info { background: var(--info-bg); border-color: #c4ddf3; color: var(--primary-2); }
.callout.warn { background: var(--warn-bg); border-color: #ecd9ae; color: #8a5a10; }
.callout.danger { background: var(--danger-bg); border-color: #f0c4bd; color: #8f2c20; }
.callout.ok { background: var(--ok-bg); border-color: #bfe5d1; color: #14613d; }

/* ---------- 搜索 ---------- */
.search-box { position: relative; margin-bottom: 16px; }
.search-box input { padding-left: 38px; font-family: var(--font); }
.search-box::before {
  content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; opacity: .6;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-2);
  border-radius: 20px; padding: 5px 14px; font-size: 12.5px; cursor: pointer; transition: .15s; font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ---------- 条款条目 ---------- */
.clause-item { display: none; }
.clause-item.show { display: block; }
.clause-item .clause-card { margin-bottom: 14px; }
.clause-item h3 { margin: 0 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clause-item .clause-ref { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.clause-item .tags { margin: 6px 0 0; }
.clause-item .tags .badge { margin-right: 6px; }
.no-result { text-align: center; color: var(--text-3); padding: 30px 0; display: none; }
.no-result.show { display: block; }

/* ---------- 单位切换 ---------- */
.unit-switch {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px; margin-bottom: 16px;
}
.unit-switch button {
  border: 0; background: transparent; padding: 6px 16px; border-radius: 6px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); font-family: inherit;
}
.unit-switch button.active { background: var(--primary); color: #fff; }

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 22px 20px; margin-top: 40px; color: var(--text-3); font-size: 12.5px;
}
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- 打印 ---------- */
@media print {
  .topbar, .footer, .btn, .menu-toggle, .menu-bar, .unit-switch, .lang-switch, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .container { padding: 10px; }
  .results { display: block !important; border: 1px solid #999; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .topbar-inner { padding: 10px 14px; gap: 10px; }
  .menu-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12);
    color: #fff; border-radius: 8px; padding: 7px 12px;
    font-size: 13.5px; font-weight: 600; font-family: inherit; cursor: pointer; flex-shrink: 0;
  }
  .menu-toggle:hover { background: rgba(255,255,255,.2); }
  .menu-bar {
    display: none; position: absolute; top: calc(100% + 6px); left: 12px; right: 12px;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: #12365c; border-radius: 12px; padding: 8px;
    box-shadow: 0 12px 24px rgba(10, 30, 55, .35); z-index: 60;
    max-height: calc(100vh - 90px); overflow-y: auto;
  }
  .menu-bar.open { display: flex; }
  .menu-link, .menu-btn { width: 100%; justify-content: flex-start; padding: 9px 12px; }
  .menu-btn { justify-content: space-between; }
  .menu-item { width: 100%; }
  .dropdown {
    position: static; display: none; min-width: 0; margin-top: 2px;
    background: rgba(255,255,255,.07); border: 0; border-radius: 8px;
    box-shadow: none; padding: 4px;
  }
  .menu-item.open .dropdown { display: block; }
  .dropdown a { color: rgba(255,255,255,.88); padding: 8px 12px; }
  .dropdown a:hover { background: rgba(255,255,255,.12); color: #fff; }
  .dropdown a.active { background: rgba(255,255,255,.2); color: #fff; }
  .topbar-right { margin-left: auto; }
  .container { padding: 16px 12px 50px; }
  .page-head h1 { font-size: 21px; }
}

@media (max-width: 700px) {
  .brand-sub { display: none; }
  .brand-name { font-size: 13.5px; letter-spacing: 0; }
  .tb-link { padding: 4px 8px; font-size: 12px; }
}

@media (max-width: 520px) {
  .brand { flex-shrink: 1; min-width: 0; }
  .brand-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .menu-toggle { padding: 6px 8px; font-size: 12px; }
  .lang-switch button { padding: 4px 7px; font-size: 12px; }
  .tb-link { padding: 4px 6px; font-size: 11.5px; }
}

/* 简单手风琴 */
details.acc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; }
details.acc summary { cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: 14px; color: var(--primary); }
details.acc summary:hover { background: var(--surface-2); }
details.acc .acc-body { padding: 0 16px 14px; border-top: 1px dashed var(--border); }

/* 步骤条 */
.steps { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 16px; }
.step {
  flex: 1; min-width: 150px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--text-2);
}
.step .s-num {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; margin-right: 6px;
}
.step b { color: var(--text); }
