:root {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #dcdcdc;
  --border-strong: #c8c8c8;
  --text: #1b1b1b;
  --text-muted: #5f5f5f;
  --accent: #0067c0;
  --accent-hover: #0b5aa0;
  --accent-soft: #e8f1fb;
  --ok: #107c10;
  --ok-soft: #e6f4e6;
  --bad: #c42b1c;
  --bad-soft: #fdeceb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Segoe UI Variable Text", -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Malgun Gothic", "Yu Gothic",
    Meiryo, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App bar ---------- */
.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.appbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, #0a84d8, #005a9e);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 8px;
  border: 2px solid #fff; border-radius: 3px;
  border-bottom-width: 4px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-size: 15px; font-weight: 600; line-height: 1.25; }
.brand-sub { font-size: 11.5px; color: var(--text-muted); line-height: 1.3; }

.appbar-actions { display: flex; gap: 8px; flex: none; }
.action-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.action-btn:hover { background: #f0f0f0; text-decoration: none; }
.action-btn:active { background: #e6e6e6; }
.action-btn svg { color: var(--accent); }

/* ---------- Menu bar ---------- */
.menubar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.menubar-inner {
  max-width: 1180px; margin: 0 auto;
  padding: 0 12px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.menu-items { display: flex; align-items: stretch; flex-wrap: wrap; }
.menu-item {
  padding: 11px 14px;
  color: var(--text);
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.menu-item:hover { background: #ececec; text-decoration: none; }
.menu-item.is-active {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
}
.menu-sep {
  width: 1px; margin: 8px 6px;
  background: var(--border);
  align-self: stretch;
}
.lang-wrap { display: flex; align-items: center; gap: 6px; padding: 6px 4px; }
.lang-label { color: var(--text-muted); display: inline-flex; }
.lang-select {
  font: inherit; font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  min-width: 128px;
}
.lang-select:focus, .field input:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 20px 40px; }
.page-head { margin: 4px 0 20px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 6px; }
.lead { color: var(--text-muted); margin: 0; max-width: 78ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card > h2 {
  font-size: 14px; font-weight: 600;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}

/* ---------- Forms ---------- */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 18px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; font-weight: 600; color: #333; }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.field input, .field select {
  font: inherit; font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
.inline-pair { display: flex; gap: 8px; }
.inline-pair input { flex: 1 1 auto; }
.inline-pair select { flex: 0 0 108px; }

.form-actions { margin-top: 16px; display: flex; gap: 10px; }
.btn {
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 18px;
  border-radius: 5px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.btn.secondary:hover { background: #f0f0f0; }

.error-msg { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 0; }
.info-msg { color: var(--text-muted); font-size: 13px; margin-top: 10px; }

/* ---------- Results ---------- */
.result-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 18px; padding: 11px 0;
  border-bottom: 1px dashed var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-label { display: flex; flex-direction: column; gap: 2px; }
.result-label .rl-main { font-size: 13.5px; }
.result-label .rl-note { font-size: 11.5px; color: var(--text-muted); }
.result-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  text-align: right;
}
.result-value .sub { font-weight: 400; font-size: 12.5px; color: var(--text-muted); }
.result-row.is-na .result-value { color: var(--text-muted); font-weight: 400; }
.result-row.is-primary { background: var(--accent-soft); border-radius: 6px; padding-left: 10px; padding-right: 10px; }

.leak-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.leak-cell {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px 14px;
  background: var(--surface-2);
}
.leak-cell .lc-label { font-size: 12px; color: var(--text-muted); min-height: 32px; }
.leak-cell .lc-value {
  font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.leak-cell .lc-unit { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .03em;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: #fff4e0; color: #9a5b00; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-block;
  padding: 4px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chip.is-strong { background: var(--accent-soft); border-color: #a9cdf0; color: #084d8f; font-weight: 600; }

.rule-note {
  margin-top: 14px; font-size: 12.5px; color: var(--text-muted);
  border-left: 3px solid var(--accent); padding: 2px 0 2px 11px;
}

/* ---------- Home cards ---------- */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.home-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  color: inherit;
}
.home-card:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 6px rgba(0,103,192,.16); }
.home-card .hc-icon {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.home-card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.home-card p { margin: 0 0 14px; color: var(--text-muted); font-size: 13px; flex: 1 1 auto; }
.home-card .hc-open { font-size: 13px; font-weight: 600; color: var(--accent); }

/* ---------- Converter ---------- */
.conv-block { margin-bottom: 6px; }
.conv-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; align-items: end; }
.conv-out {
  background: var(--accent-soft); border: 1px solid #cfe3f7; border-radius: 6px;
  padding: 9px 12px; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums;
  min-height: 38px; display: flex; align-items: center;
}
.conv-out small { font-weight: 400; color: var(--text-muted); margin-left: 6px; font-size: 12.5px; }

/* ---------- Footer ---------- */
.appfooter { background: #ececec; border-top: 1px solid var(--border); margin-top: 24px; }
.footer-inner { max-width: 1180px; margin: 0 auto; padding: 22px 20px 30px; }
.disclaimer {
  background: #fffbe6; border: 1px solid #f0e0a8; border-left: 4px solid #d9a600;
  border-radius: 6px; padding: 14px 16px;
}
.disclaimer-title { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: #7a5c00; text-transform: uppercase; letter-spacing: .04em; }
.disclaimer p { margin: 0; font-size: 12.5px; color: #55482a; line-height: 1.6; }
.footer-meta {
  margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-muted);
}
.footer-dot { color: var(--border-strong); }

/* ---------- Acceptance check ---------- */
.check-toggle {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 600; color: #333;
  margin-bottom: 14px;
}
.check-toggle input { width: 16px; height: 16px; flex: none; }
.check-toggle .hint { display: block; font-weight: 400; color: var(--text-muted); font-size: 11.5px; }

.check-list { display: flex; flex-direction: column; }
.check-row {
  display: grid;
  grid-template-columns: 1fr 132px 108px;
  gap: 12px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.check-row:last-child { border-bottom: none; }
.check-row .ck-label { font-size: 13px; }
.check-row .ck-label .hint { display: block; font-size: 11.5px; color: var(--text-muted); }
.check-row input {
  font: inherit; font-size: 14px; padding: 7px 9px;
  border: 1px solid var(--border-strong); border-radius: 5px;
  width: 100%; text-align: right;
}
.check-row .ck-verdict { text-align: right; }
.check-row .ck-verdict .badge { min-width: 64px; text-align: center; }
.check-row .ck-none { color: var(--text-muted); font-size: 13px; }

.overall {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 16px; border-radius: 7px;
}
.overall.ok { background: var(--ok-soft); border: 1px solid #bfe0bf; }
.overall.bad { background: var(--bad-soft); border: 1px solid #f2c4c0; }
.overall .ov-title { font-size: 14px; font-weight: 700; }
.overall.ok .ov-title { color: var(--ok); }
.overall.bad .ov-title { color: var(--bad); }
.overall .ov-note { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.overall .badge { font-size: 14px; padding: 5px 14px; }

/* ---------- Setup ---------- */
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.set-cell {
  border: 1px solid var(--border); border-radius: 7px;
  padding: 12px 14px; background: var(--surface-2);
}
.set-cell .sc-label { font-size: 12px; color: var(--text-muted); min-height: 32px; }
.set-cell .sc-value {
  font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px;
}
.set-cell .sc-unit { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.set-cell.is-ok .sc-value { color: var(--ok); }
.set-cell.is-bad .sc-value { color: var(--bad); }

/* ---------- Fire test timeline ---------- */
.timeline { border-left: 2px solid var(--border-strong); margin-left: 5px; padding-left: 16px; }
.tl-row {
  position: relative;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.tl-row:last-child { border-bottom: none; }
.tl-row::before {
  content: ""; position: absolute; left: -21px; top: 12px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
}
.tl-label { font-size: 13px; }
.tl-value {
  font-size: 13.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tl-value .sub { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: 2px; }

/* ---------- Staged leakage ---------- */
.stage-scroll { overflow-x: auto; }
.stage-head, .stage-row {
  display: grid;
  grid-template-columns: 1fr 92px 92px 104px 104px 92px;
  gap: 10px; align-items: center;
}
.stage-head {
  padding: 8px 0;
  font-size: 11.5px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
}
.stage-head .sh-num, .stage-row .st-num { text-align: right; }
.stage-row { padding: 9px 0; border-bottom: 1px dashed var(--border); }
.stage-row:last-child { border-bottom: none; }
.stage-row.is-disabled { opacity: .45; }
.stage-row .st-label { font-size: 13px; }
.stage-row input {
  font: inherit; font-size: 13.5px; padding: 6px 8px;
  border: 1px solid var(--border-strong); border-radius: 5px;
  width: 100%; min-width: 0; text-align: right;
}
.stage-row .st-num { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.stage-row .st-verdict { text-align: right; }
.stage-row .st-verdict .badge { min-width: 60px; text-align: center; }
.stage-row .st-none { color: var(--text-muted); font-size: 13px; }

/* ---------- Progress bar (report checklist) ---------- */
.progress {
  height: 8px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0;
  background: var(--accent);
  transition: width .18s ease;
}
.progress-bar.is-ok { background: var(--ok); }

/* ---------- Test record / export ---------- */
.export-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.sub-head {
  margin: 20px 0 8px;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em;
}
.record-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.rec-row {
  display: flex; gap: 16px; align-items: baseline;
  padding: 8px 14px;
  border-bottom: 1px dashed var(--border);
}
.rec-row:last-child { border-bottom: 0; }
.rec-k { flex: 0 0 46%; color: var(--text-muted); font-size: 13px; }
.rec-v { flex: 1 1 auto; font-size: 13px; font-weight: 600; text-align: right; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .appbar-inner { padding: 10px 14px; }
  .check-row { grid-template-columns: 1fr 96px 86px; gap: 8px; }
  .stage-head, .stage-row { min-width: 520px; }
  .container { padding: 16px 14px 32px; }
  .menubar-inner { padding: 0 6px; }
  .menu-item { padding: 10px 10px; font-size: 13px; }
  .lang-wrap { width: 100%; justify-content: flex-end; padding-bottom: 8px; }
  .conv-grid { grid-template-columns: 1fr; }
  .appbar-actions { width: 100%; }
  .action-btn { flex: 1 1 auto; justify-content: center; }
}
