:root {
  --navy: #10243e;
  --navy2: #16324f;
  --accent: #d9822b;
  --accent2: #2f7d5c;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #dfe4ea;
  --text: #1c2733;
  --muted: #64748b;
  --pass: #1e7f4f;
  --pass-bg: #e6f6ec;
  --fail: #b3261e;
  --fail-bg: #fbe9e7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand-title { font-size: 18px; font-weight: 700; display:block; }
.brand-sub { font-size: 12px; color: #b9c6d6; display:block; margin-top: 2px; }

.btn {
  background: var(--accent2);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border: 1px solid #4c6683; color: #fff; }
.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.stiff-dims[hidden] { display: none !important; }
.btn-danger { background: var(--fail); }

.disclaimer {
  background: #fff4e5;
  border-bottom: 1px solid #f0d9ad;
  color: #7a4b00;
  font-size: 12.5px;
  padding: 8px 24px;
  line-height: 1.5;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--navy2);
  padding: 0 20px;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  color: #cddaeb;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.tab-btn:hover { color: #fff; }
.tab-btn.active { color: #fff; border-bottom-color: var(--accent); }

main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

h2 { margin-top: 0; font-size: 20px; }
h3 { margin-top: 0; font-size: 14px; color: var(--navy2); border-bottom: 1px solid var(--border); padding-bottom: 8px; }

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 600; }
label.checkbox input { width: auto; }

input[type="number"], input[type="text"], select {
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

input[type="number"].linked-input {
  background: #f1f8f4;
  border-color: #a9d3bd;
}
.link-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.link-badge:hover { border-color: var(--accent); color: var(--accent); }
.link-badge.is-linked {
  border-color: #a9d3bd;
  background: #eaf5ef;
  color: var(--pass);
  cursor: default;
}

.item-list { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }

.item-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.item-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.item-card-head .tag { font-weight: 700; font-size: 14px; }

.result-card { background: #f9fbfd; overflow-x: auto; }

table.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}
table.calc-table th, table.calc-table td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
}
table.calc-table th { background: #eef2f6; color: var(--navy2); }
table.calc-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.pass { background: var(--pass-bg); color: var(--pass); }
.badge.fail { background: var(--fail-bg); color: var(--fail); }

.formula-note { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-style: italic; }

.section-title {
  font-size: 13px; font-weight: 700; color: var(--navy2);
  margin: 14px 0 6px;
}

.inline-fields { display: flex; gap: 8px; margin-top: 5px; }
.inline-fields input { margin-top: 0; flex: 2; }
.inline-fields select { margin-top: 0; flex: 1; }

.caution-box {
  background: #fff4e5;
  border: 1px solid #f0d9ad;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.6;
}
.caution-box.severe { background: #fbe9e7; border-color: #f0b4ab; border-left-color: var(--fail); }
.caution-box h4 { margin: 0 0 6px; font-size: 13px; }
.caution-box ul { margin: 4px 0; padding-left: 18px; }
.caution-box li { margin-bottom: 4px; }

details.code-basis {
  margin-top: 8px;
  background: #f3f6fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}
details.code-basis summary { cursor: pointer; font-weight: 700; color: var(--navy2); }
details.code-basis .trace { margin-top: 6px; font-family: "Consolas","Menlo",monospace; white-space: pre-wrap; color: #334; line-height: 1.6; }

.two-col-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px;
}

@media print {
  .topbar, .tabs, .disclaimer, #btnPrint, .btn { display: none !important; }
  .tab-panel { display: block !important; page-break-after: always; }
  body { background: #fff; }
}
