/* ============ 保安図作成アプリ（モック） ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #1f2933;
  background: #eef1f4;
  display: flex;
  flex-direction: column;
}

/* ---------- ヘッダー ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: #14314f;
  color: #fff;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 30px; }
.brand h1 { font-size: 18px; letter-spacing: .05em; }
.brand-sub { font-size: 11px; color: #a8c3de; }

.steps { display: flex; list-style: none; gap: 4px; flex-wrap: wrap; }
.steps li {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  font-size: 12.5px;
  border-radius: 20px;
  background: rgba(255,255,255,.08);
  color: #9db8d2;
}
.steps li .num {
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: bold;
}
.steps li.active { background: #f6a41c; color: #14314f; font-weight: bold; }
.steps li.active .num { background: #14314f; color: #fff; }
.steps li.done { color: #d7e5f2; }
.steps li.done .num { background: #2e7d32; color: #fff; }

/* ---------- メイン ---------- */
.app-main { flex: 1; display: flex; min-height: 0; }

.panel {
  width: 380px;
  min-width: 320px;
  background: #fff;
  border-right: 1px solid #d8dee5;
  overflow-y: auto;
  padding: 18px;
}
.panel h2 { font-size: 15.5px; color: #14314f; margin-bottom: 8px; }
.panel h3.form-title {
  font-size: 13px; color: #14314f; margin: 18px 0 8px;
  border-left: 4px solid #f6a41c; padding-left: 8px;
}
.hint { font-size: 12px; color: #5b6b7b; line-height: 1.6; margin-bottom: 10px; }
.hint.small { font-size: 11px; }
.hidden { display: none !important; }

/* 検索 */
.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1; padding: 10px 12px; font-size: 14px;
  border: 2px solid #c3ccd6; border-radius: 8px;
}
.search-row input:focus { outline: none; border-color: #f6a41c; }
.candidates { list-style: none; margin-top: 10px; }
.candidates li {
  padding: 10px 12px; font-size: 13px;
  border: 1px solid #d8dee5; border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; background: #f8fafc;
}
.candidates li:hover { background: #fff4dd; border-color: #f6a41c; }

/* 確認カード */
.confirm-card {
  margin-top: 14px; padding: 14px;
  border: 2px solid #f6a41c; border-radius: 10px; background: #fffaf0;
}
.confirm-card h3 { font-size: 14px; color: #14314f; margin-bottom: 6px; }
.confirm-addr { font-size: 13.5px; font-weight: bold; color: #b45309; margin-bottom: 6px; }

/* ボタン */
.btn {
  border: none; cursor: pointer; border-radius: 8px;
  font-size: 13px; padding: 10px 14px;
  background: #e2e8f0; color: #1f2933;
  transition: filter .15s;
}
.btn:hover { filter: brightness(.95); }
.btn.primary { background: #f6a41c; color: #14314f; font-weight: bold; }
.btn.ghost { background: #eef1f4; border: 1px solid #c3ccd6; }
.btn.big { padding: 14px; font-size: 15px; }
.btn.small { padding: 5px 10px; font-size: 11.5px; }
.btn-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn-row.col { flex-direction: column; }

/* 計測 */
.mode-btns { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.btn.mode { text-align: left; background: #eef4fb; border: 1px solid #c3d4e8; }
.btn.mode.active { background: #14314f; color: #fff; border-color: #14314f; }
.measure-status {
  font-size: 12px; padding: 8px 10px; border-radius: 8px;
  background: #f1f5f9; color: #33475b; margin-bottom: 4px;
}
.measure-status.measuring { background: #fff4dd; color: #b45309; font-weight: bold; }

/* 寸法フォーム */
.dim-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.dim-form label { font-size: 11.5px; color: #33475b; display: flex; flex-direction: column; gap: 3px; }
.input-unit { display: flex; align-items: center; gap: 4px; }
.input-unit input {
  width: 100%; padding: 7px 8px; font-size: 14px;
  border: 1.5px solid #c3ccd6; border-radius: 6px;
}
.input-unit em { font-style: normal; font-size: 11px; color: #5b6b7b; white-space: nowrap; }
.auto-badge:not(:empty) {
  font-size: 10px; background: #2e7d32; color: #fff;
  border-radius: 4px; padding: 1px 5px; margin-left: 4px;
}

/* 規制方式 */
.reg-radios { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.reg-radios label.disabled { color: #9aa8b5; }
.reg-desc { display: block; font-size: 10.5px; color: #7a8896; margin-left: 22px; }
.soon { font-size: 10px; background: #cbd5e0; color: #4a5a68; border-radius: 4px; padding: 1px 6px; }

/* 保存済み案件 */
.cases-box { margin-top: 20px; }
.case-list { list-style: none; }
.case-list li {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid #d8dee5; border-radius: 8px;
  padding: 8px 10px; margin-bottom: 6px; background: #f8fafc; font-size: 12px;
}
.case-list .case-info { flex: 1; min-width: 0; cursor: pointer; }
.case-list .case-name { font-weight: bold; color: #14314f; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-list .case-meta { font-size: 10.5px; color: #7a8896; }
.case-list .case-del {
  border: none; background: none; color: #c01c28; cursor: pointer; font-size: 14px; padding: 4px;
}
.save-msg:not(:empty) {
  margin-top: 10px; font-size: 12px; font-weight: bold; color: #2e7d32;
  background: #e8f5e9; border-radius: 8px; padding: 8px 10px;
}

/* 標識ドラッグ */
.drag-sign { cursor: grab; }
.drag-sign.dragging { cursor: grabbing; }
.drag-sign circle { transition: stroke-width .1s; }
.drag-sign:hover circle { stroke-width: 3; }

/* 標識グリッド */
.sign-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sign-card {
  border: 2px solid #d8dee5; border-radius: 10px;
  padding: 8px 4px 6px; text-align: center; cursor: pointer;
  background: #fff; position: relative;
}
.sign-card.selected { border-color: #f6a41c; background: #fffaf0; }
.sign-card .sign-num {
  position: absolute; top: -8px; left: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #14314f; color: #fff; font-size: 11px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
}
.sign-card svg { width: 56px; height: 62px; }
.sign-card .sign-name { font-size: 10px; color: #33475b; display: block; margin-top: 2px; line-height: 1.3; }
.sign-card .check {
  position: absolute; top: -7px; right: -5px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #2e7d32; color: #fff; font-size: 12px;
  display: none; align-items: center; justify-content: center;
}
.sign-card.selected .check { display: flex; }
.dist-checks { display: flex; gap: 14px; font-size: 13px; }

/* ---------- 地図・ステージ ---------- */
.stage { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.layer-switch {
  position: absolute; top: 12px; right: 12px; z-index: 900;
  display: flex; gap: 4px; background: #fff; padding: 4px; border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.layer-switch .btn.active { background: #14314f; color: #fff; }

.measure-label {
  background: #14314f; color: #fff; font-size: 12px; font-weight: bold;
  padding: 2px 8px; border-radius: 6px; border: none;
  white-space: nowrap;
}
.measure-label::before { display: none; }

/* ---------- 保安図シート ---------- */
.sheet-wrap {
  position: absolute; inset: 0; overflow: auto;
  background: #8a94a0; padding: 24px; z-index: 950;
}
.sheet {
  width: 1123px;              /* A4横 297mm @96dpi ≒ 1123px */
  min-height: 794px;          /* 210mm */
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  padding: 24px 28px;
  display: flex; flex-direction: column; gap: 10px;
}

.sheet-titlebar {
  display: flex; border: 2.5px solid #1f2933;
}
.sheet-titlebar .cell {
  padding: 6px 12px; font-size: 13px; display: flex; align-items: center; gap: 10px;
}
.sheet-titlebar .cell.head {
  background: #14314f; color: #fff; font-weight: bold; white-space: nowrap;
}
.sheet-titlebar .cell.grow { flex: 1; border-left: 1.5px solid #1f2933; }
.sheet-titlebar .zumei { font-size: 16px; font-weight: bold; letter-spacing: .06em; }

.sheet-body { display: flex; gap: 10px; flex: 1; min-height: 0; }
.sheet-plan { flex: 1; border: 1.5px solid #1f2933; position: relative; display: flex; }
.sheet-plan svg { width: 100%; height: 100%; }
.sheet-side { width: 240px; display: flex; flex-direction: column; gap: 10px; }
.sheet-map {
  border: 1.5px solid #1f2933;
}
.sheet-map .cap {
  font-size: 11px; font-weight: bold; background: #eef1f4;
  padding: 3px 8px; border-bottom: 1px solid #1f2933;
}
.sheet-map img, .sheet-map canvas { width: 100%; display: block; }
.sheet-map .attr { font-size: 8.5px; color: #5b6b7b; padding: 2px 6px; }
.sheet-notes { border: 1.5px solid #1f2933; padding: 8px 10px; font-size: 10.5px; line-height: 1.7; flex: 1; }
.sheet-notes b { color: #c01c28; }

.sheet-legend { border: 2px solid #1f2933; }
.sheet-legend .cap {
  font-size: 11.5px; font-weight: bold; background: #eef1f4;
  padding: 3px 8px; border-bottom: 1.5px solid #1f2933;
}
.legend-row { display: flex; }
.legend-cell {
  flex: 1; border-right: 1px solid #1f2933; text-align: center;
  padding: 6px 2px 4px; min-width: 0;
}
.legend-cell:last-child { border-right: none; }
.legend-cell svg { height: 62px; max-width: 100%; }
.legend-cell .n {
  display: inline-flex; width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid #1f2933; font-size: 11px; font-weight: bold;
  align-items: center; justify-content: center; margin-bottom: 2px;
}
.legend-cell .nm { display: block; font-size: 8.5px; color: #33475b; line-height: 1.25; }

/* ---------- フッター ---------- */
.app-footer {
  padding: 8px 20px; background: #dde3e9; font-size: 10.5px; color: #5b6b7b; line-height: 1.6;
}
.app-footer a { color: #14314f; }
.app-footer .credit { font-weight: bold; }

/* ---------- 印刷専用レイヤー（printRoot方式・全ブラウザ対応） ---------- */
#printRoot { display: none; }
@media print {
  /* 印刷ボタン経由: body直下のprintRootだけを印刷する */
  body.printing > *:not(#printRoot) { display: none !important; }
  body.printing #printRoot { display: block !important; position: static; }
  body.printing #printRoot .sheet {
    width: auto; min-height: 0; box-shadow: none; margin: 0; padding: 0;
  }
}

/* ---------- 印刷 ---------- */
@page { size: A4 landscape; margin: 8mm; }
@media print {
  .no-print, .panel, .layer-switch, #map { display: none !important; }
  html, body { height: auto; background: #fff; display: block;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .app-main { display: block; height: auto; }
  .stage { position: static; min-height: 0; }
  .sheet-wrap {
    position: static; overflow: visible; background: #fff; padding: 0;
    display: block !important;
  }
  .sheet {
    width: auto; min-height: 0; box-shadow: none; margin: 0; padding: 0;
  }
  .sheet-plan svg { height: auto; }
  .sheet-map img, .sheet-map canvas { max-height: 200px; object-fit: cover; }
}

/* ---------- スマホ ---------- */
@media (max-width: 820px) {
  .app-main { flex-direction: column; }
  .panel { width: 100%; min-width: 0; max-height: 45vh; border-right: none; border-bottom: 1px solid #d8dee5; }
  .stage { min-height: 55vh; }
  .sheet { width: 1123px; } /* 横スクロールで閲覧 */
}
