:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #5b6b7b;
  --line: #dce3ea;
  --brand: #1457b8;
  --brand-2: #0e3f86;
  --accent: #0f9d8b;
  --warn-bg: #fff7e6;
  --warn-line: #f0c469;
  --shadow: 0 1px 3px rgba(20, 40, 70, .08), 0 4px 16px rgba(20, 40, 70, .06);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans CJK JP", "Noto Sans CJK KR", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }

/* Top bar */
.topbar {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 18px;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .35);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-action:hover { background: rgba(255, 255, 255, .26); }
.lang-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.lang-label { opacity: .85; }
#lang-select {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: #fff;
  color: var(--ink);
  padding: 5px 8px;
  font-size: 13px;
}
.mainnav {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, .18);
}
.mainnav a {
  color: #eaf1fb;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
}
.mainnav a:hover { color: #fff; background: rgba(255, 255, 255, .10); }
.mainnav a.active { color: #fff; border-bottom-color: var(--accent); }

/* Layout */
.container { max-width: 1080px; margin: 0 auto; padding: 22px 18px 40px; }
h1 { font-size: 24px; margin: 6px 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.intro { color: var(--muted); margin: 0 0 18px; max-width: 760px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

/* Module grid on home */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.module-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.module-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(20,40,70,.14); border-color: var(--brand); }
.module-card .ico { font-size: 26px; }
.module-card h3 { margin: 8px 0 4px; font-size: 16px; color: var(--brand); }
.module-card p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* Forms */
.form-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 90px;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 12px;
}
.form-row label { font-weight: 600; font-size: 14px; }
.form-row input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.form-row .unit { color: var(--muted); font-size: 13px; }
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr 88px; }
  .form-row label { grid-column: 1 / -1; }
}

.actions { display: flex; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; }
.btn {
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: #eef2f7; color: var(--ink); }
.btn-ghost:hover { background: #e1e8f0; }

/* Sample project library bar (P27+) */
.sample-bar { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-left: 10px; margin-left: 4px; border-left: 1px solid var(--line, #d7dee8); }
.sample-bar .sample-msg { font-size: 12px; color: var(--ok, #1a7f37); margin-left: 2px; }
.cmp-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink); margin-left: 6px; }
.cmp-chk input { width: auto; }

/* Result */
.result-out { margin-top: 6px; }
.result-out table { width: 100%; border-collapse: collapse; font-size: 14px; }
.result-out th, .result-out td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.result-out th { color: var(--muted); font-weight: 600; width: 58%; }
.result-out td.val { font-weight: 700; color: var(--brand-2); }
.note {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-left: 4px solid var(--warn-line);
  border-radius: 10px;
  padding: 12px 14px;
  color: #6b4e12;
  font-size: 13.5px;
  margin-top: 16px;
}
.note b { color: #5a3d00; }

/* Alloy table */
.table-tools { margin-bottom: 12px; }
.table-tools input {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  width: 260px;
  max-width: 100%;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
table.data th, table.data td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
table.data th:nth-child(1), table.data td:nth-child(1),
table.data th:nth-child(2), table.data td:nth-child(2) { text-align: left; }
table.data thead th { background: #eef2f7; position: sticky; top: 0; }
table.data tbody tr:hover { background: #f3f7fc; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background: #eef2f7;
  color: var(--muted);
  padding: 16px 18px;
  font-size: 12.5px;
  text-align: center;
}
.site-footer .foot-links { margin-top: 4px; }
.site-footer .foot-links a { font-weight: 600; }

/* Charts */
.chart-wrap { width: 100%; overflow-x: auto; background: #fff; border-radius: 10px; }
.chart-wrap svg { display: block; }

/* Report card */
.sec-h { margin: 18px 0 6px; font-size: 15px; color: #1f6feb; border-left: 3px solid #1f6feb; padding-left: 8px; }
table.rep { width: 100%; border-collapse: collapse; }
table.rep th, table.rep td { padding: 8px 10px; border-bottom: 1px solid #e2e5ea; text-align: left; }
table.rep th { width: 55%; color: #5a6472; font-weight: 600; }
table.rep td.val { text-align: right; font-variant-numeric: tabular-nums; }
.meta { font-size: 13px; color: #5a6472; margin: 6px 0 14px; }
.foot-disc { margin-top: 16px; font-size: 11.5px; color: #5a6472; border-top: 1px dashed #e2e5ea; padding-top: 8px; }

/* Print / export: show only the working area */
@media print {
  .topbar, .site-footer, .module-grid, .no-print, .btn-row, .note, .intro, .form-grid { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .container { max-width: 100%; padding: 0; }
  .sec-h { color: #000; border-color: #000; }
  #card { display: block !important; }
}

/* Module pages: buttons, result tables, charts, verdicts */
.btn-row { display: flex; gap: 10px; margin: 6px 0 16px; flex-wrap: wrap; }
.result-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 6px; }
.result-table th, .result-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.result-table th { color: var(--muted); font-weight: 600; width: 58%; }
.result-table td.val { font-weight: 700; color: var(--brand-2); text-align: right; }

.curve-wrap { width: 100%; overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin: 8px 0 14px; }
.curve-wrap svg { display: block; width: 100%; height: auto; }
.grid { stroke: #e6ecf2; stroke-width: 1; }
.ax { fill: #8493a3; font-size: 11px; }
.curve { fill: none; stroke: var(--brand); stroke-width: 2.4; }
.vline { stroke: #d04a3b; stroke-width: 1.4; stroke-dasharray: 4 3; }
.cursor { fill: #d04a3b; }
.ph-pre { fill: rgba(20,87,184,.06); }
.ph-boost { fill: rgba(15,157,139,.10); }
.ph-hold { fill: rgba(20,87,184,.10); }
.ph-rel { fill: rgba(120,120,120,.06); }
.mk-cur { stroke: #d04a3b; stroke-width: 1.6; stroke-dasharray: 4 3; }
.mk-allow { stroke: #0f9d8b; stroke-width: 1.6; stroke-dasharray: 4 3; }

.inv-box { background: #fbfdff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 14px 0; }
.verdict { font-weight: 700; padding: 8px 12px; border-radius: 8px; margin: 8px 0; }
.verdict.pass { background: #e6f7ee; color: #0a7a4f; border: 1px solid #9bd9bd; }
.verdict.marginal { background: #fff6e0; color: #b8860b; border: 1px solid #f0d89a; }
.verdict.fail { background: #fdeceb; color: #c0392b; border: 1px solid #f0b4ad; }

.feeder { margin-top: 10px; }
.feeder-note { color: var(--muted); font-size: 13px; margin-top: 6px; }
.phase-readout { font-weight: 600; color: var(--brand-2); margin: 6px 0 14px; }

.link-banner {
  background: #f0f7ff;
  border: 1px solid #b9d4f5;
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0 14px;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.link-banner .lb-msg { font-weight: 600; }
.link-banner .btn-ghost { margin-left: auto; }

.card-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 10px 0; }
.card-table th, .card-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.card-table th { color: var(--muted); font-weight: 600; background: #eef2f7; }
.card-table td.val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand-2); }
.empty { color: var(--muted); padding: 14px; border: 1px dashed var(--line); border-radius: 10px; }
/* P3⑩ multi-version process management */
.versions-block { margin-top: 22px; border-top: 2px dashed var(--line); padding-top: 16px; }
.versions-block h2 { font-size: 17px; margin: 4px 0 12px; }
.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 2px 4px; text-decoration: underline; }
.btn-link:hover { color: var(--brand-2); }
/* D cyclic thermal-fatigue phased-history block */
.sub-grid { margin: 6px 0 4px; padding: 10px 12px 4px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; }
.sub-grid .form-row { margin-bottom: 6px; }
.toggle-row { display: flex; align-items: center; }
.toggle-row input { width: auto; margin-right: 8px; }
.card-table.cmp { margin-top: 14px; }
.card-table.cmp th { background: #eaf2ea; }
/* P2-2 version-overlay metric selector */
.metric-sel { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 10px; padding: 8px 10px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; }
.metric-sel .ovm { display: inline-flex; align-items: center; font-size: 12px; color: var(--ink); cursor: pointer; }
.metric-sel .ovm input { width: auto; margin-right: 5px; }
