/* フェア用の画面（スマホ前提。タブレット・PC でも崩れないよう最大幅で中央寄せ）。背景は白で、印刷（PDF）も同じ見た目 */
:root {
  color-scheme: light;
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f3f5f8; --border: #dde2e8;
  --text: #17202b; --muted: #5d6877; --accent: #1f6feb; --accent-ink: #ffffff; --accent-soft: #e8f0fe;
  --warn-bg: #fff6e0; --warn-border: #e8b64c; --warn-text: #6b4a00;
  --err-bg: #fdecec; --err-border: #e5a0a0; --err-text: #8a1f1f; --ok: #1a7f37;
  --point: rgba(31, 111, 235, .35); --target: #d1242f; --bar: #1f6feb;
  --same: rgba(232, 133, 12, .85); --same-line: #b35f00; --ref: rgba(120, 128, 140, .55); --ref-past: rgba(120, 128, 140, .25);
  --pos: #1a7f37; --neg: #c0392b;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
header.top { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
header.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
header.top h1 { font-size: 17px; margin: 0; white-space: nowrap; }
header.top .who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
main { padding: 16px 0 56px; }
h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 700; flex: none; }
section.block { padding: 16px 0; border-bottom: 1px solid var(--border); }
section.block:last-of-type { border-bottom: 0; }
.hint, .note { color: var(--muted); font-size: 13px; }
.hint { margin: 0 0 10px; }
.note { margin: 8px 0 0; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
input, select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; }   /* 16px 未満だと iPhone が拡大する */
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid .wide { grid-column: 1 / -1; }
.grid > .field { min-width: 0; }   /* 築年月（month）などの入力の最小幅で列がずれないように */
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.field.missing input, .field.missing select { border-color: var(--warn-border); background: var(--warn-bg); }
.tag { font-size: 11px; padding: 0 6px; border-radius: 4px; margin-left: 4px; background: var(--surface-2); color: var(--muted); }
.tag.req { background: var(--warn-bg); color: var(--warn-text); }
button { font: inherit; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px; font-weight: 600; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-size: 14px; text-decoration: underline; cursor: pointer; }
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kinds label { margin: 0; display: flex; flex-direction: column; justify-content: center; min-height: 64px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; }
.kinds label small { font-weight: 400; color: var(--muted); font-size: 12px; }
.kinds input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kinds label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.kinds label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.kinds label.off { opacity: .45; cursor: not-allowed; }
.results { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; max-height: 50vh; overflow: auto; }
.results li { padding: 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.results li:last-child { border-bottom: 0; }
.results li:active, .results li:hover, .results li:focus { background: var(--surface-2); outline: none; }
.results .name { font-weight: 600; }
.results .sub { color: var(--muted); font-size: 13px; }
.selected { margin-top: 10px; padding: 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; }
.msg { padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: 14px; border: 1px solid; }
.msg.err { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.msg.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.msg.ok { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.mylist { list-style: none; padding: 0; margin: 0; }
.mylist li { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.mylist a { display: block; padding: 10px 12px; color: inherit; text-decoration: none; }
.mylist .sub { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.login { max-width: 420px; margin: 24px auto; }
.login input { font-size: 22px; letter-spacing: .08em; text-align: center; }

/* ---- 結果（社内用と同じ内容） ---- */
.result-head { margin: 4px 0 8px; }
.price { font-size: 36px; font-weight: 800; line-height: 1.2; margin: 4px 0; }
.price small { font-size: 16px; font-weight: 600; margin-left: 2px; }
.breakdown { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px; min-width: 0; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.kpi .s { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.split .c { background: var(--ok); } .split .x { background: var(--bar); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.same { background: var(--same); border: 1px solid var(--same-line); }
.dot.ref { background: var(--ref); } .dot.ref.past { background: var(--ref-past); }
.dot.ring { border: 1.5px solid var(--ref); background: none; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 10px; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
table.t th, table.t td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.t th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: 12px; }
table.t tr:last-child td { border-bottom: 0; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.ref td { color: var(--muted); }
table.t .sub { color: var(--muted); font-size: 11px; }
.flag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); margin-right: 3px; }
.flag.same { background: #fff0dc; color: var(--same-line); }
.flag.caution { background: var(--warn-bg); color: var(--warn-text); }
.flag.review { background: var(--err-bg); color: var(--err-text); }
.tbl-block { margin-top: 12px; }
.tbl-block h3 { font-size: 14px; }
details { margin: 8px 0; }
details > summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; }
.bars { display: grid; grid-template-columns: minmax(84px, 30%) 1fr auto; gap: 6px 8px; align-items: center; font-size: 13px; }
.bars .track { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; }
.bars .fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.bars .fill.pos { background: var(--pos); } .bars .fill.neg { background: var(--neg); }
.bars .pct { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hazard { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 640px) { .hazard { grid-template-columns: 1fr 1fr; } }
.hazard > div { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 14px; }
.hazard .none { color: var(--muted); } .hazard .lv1 { color: #8a6a00; } .hazard .lv2 { color: #b35f00; font-weight: 600; } .hazard .lv3 { color: var(--err-text); font-weight: 700; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.contract-estimate { font-weight: 600; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.tools .wide { grid-column: 1 / -1; }
.expiry { font-size: 13px; color: var(--muted); }

/* ---- 印刷・PDF（?print=1 でも同じ見た目にする） ---- */
.print-only { display: none; }
@media print {
  header.top { position: static; }
  .no-print, .tools, .linkbtn.show-all { display: none !important; }
  .print-only { display: block; }
  body { font-size: 12px; }
  .wrap { max-width: none; padding: 0; }
  .price { font-size: 28px; }
  .tbl-wrap { overflow: visible; border: 0; }
  table.t { font-size: 10px; }
  table.t th, table.t td { padding: 3px 4px; }
  tr, .kpi, .chart, .hazard > div { break-inside: avoid; }
  /* デザイナー指示（2026-10-21）: 3 ページもの。散布図の下と、ハザードの前で改ページ。各パーツを囲む角丸の罫線は付けない */
  .chart.page-end { break-after: page; }
  #hazardBox { break-before: page; }
  .msg, .tbl-wrap, .selected, .mylist li { border: 0 !important; border-radius: 0 !important; }
  .msg { padding: 4px 0; background: none !important; }
  h2, h3 { break-after: avoid; }
}
