/* ky-nippo ひな形 共通スタイル
   ※これは見せるためのモックアップ。保存機能はありません */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --ink: #1a1d21;
  --sub: #5b636d;
  --line: #c9ced6;
  --line-strong: #7b838e;
  --bg: #eef1f5;
  --paper: #fff;
  --accent: #0b57a4;
  --accent-soft: #e8f0fa;
  --warn: #c62828;
  --ok: #1b7a3d;
  --field: #fffdf2;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); }

/* ---------- ヘッダ ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--accent); color: #fff;
}
.appbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.appbar .spacer { flex: 1; }
.appbar .who { font-size: 13px; opacity: .9; }
.appbar a { color: #fff; text-decoration: none; font-size: 14px; }
.back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 8px;
  background: rgba(255,255,255,.15); font-size: 20px;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }

.mock-note {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: #fff6d8; border: 1px solid #e6cf7a; border-radius: 8px;
  font-size: 13px; color: #6b5300;
}

/* ---------- 紙の帳票を模した枠 ---------- */
.paper {
  background: var(--paper);
  border: 2px solid var(--line-strong);
  padding: 14px 16px 20px;
}
.paper-title {
  text-align: center; font-size: 22px; font-weight: 700;
  letter-spacing: .3em; margin: 4px 0 14px;
}

.sec {
  border: 1px solid var(--line-strong);
  margin-bottom: 10px;
}
.sec > h2 {
  margin: 0; padding: 6px 10px;
  font-size: 14px; font-weight: 700;
  background: #e9edf3; border-bottom: 1px solid var(--line-strong);
}
.sec > .body { padding: 10px; }

/* ---------- 入力 ---------- */
label { font-size: 13px; color: var(--sub); display: block; margin-bottom: 3px; }
input[type=text], input[type=date], input[type=number], textarea, select {
  width: 100%; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--field);
  font-family: inherit; font-size: 16px; color: var(--ink);
}
textarea { resize: vertical; }
select { background-color: var(--field); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.grid { display: grid; gap: 10px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 820px) { .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* チェック（タップしやすく） */
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chk {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; min-height: 48px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-size: 15px; cursor: pointer; user-select: none;
}
.chk input { width: 22px; height: 22px; accent-color: var(--accent); }
.chk:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }

/* ---------- テーブル ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid var(--line); padding: 6px 8px; font-size: 14px; }
th { background: #e9edf3; font-weight: 700; white-space: nowrap; }
td input, td select, td textarea { border: none; background: transparent; padding: 6px 4px; }
td input:focus, td select:focus, td textarea:focus { background: var(--field); }
.num { text-align: center; width: 52px; background: #f4f6f9; font-weight: 700; }

/* リスク評価の結果セル */
.calc { text-align: center; font-weight: 700; background: #f4f6f9; width: 70px; }
.rank { text-align: center; font-weight: 700; width: 70px; }
.rank[data-rank="Ⅴ"], .rank[data-rank="Ⅳ"] { background: #fde8e8; color: var(--warn); }
.rank[data-rank="Ⅲ"] { background: #fff3d9; color: #8a6100; }
.rank[data-rank="Ⅱ"], .rank[data-rank="Ⅰ"] { background: #e8f5ec; color: var(--ok); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--ink);
  font-size: 16px; font-weight: 700; font-family: inherit;
  cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn:active { transform: translateY(1px); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.actions .spacer { flex: 1; }

/* ---------- 現場ホームのタイル ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 160px; padding: 22px;
  background: #fff; border: 2px solid var(--line-strong); border-radius: 14px;
  text-decoration: none; color: var(--ink);
}
.tile .ico { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.tile .t { font-size: 22px; font-weight: 700; }
.tile .d { font-size: 14px; color: var(--sub); margin-top: 4px; }
.tile.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.tile.accent .d { color: rgba(255,255,255,.85); }

/* ---------- 広告枠 ---------- */
.ad {
  margin-top: 18px; padding: 14px 16px;
  background: linear-gradient(135deg, #10375e, #1d6fb8);
  color: #fff; border-radius: 12px;
  display: flex; align-items: center; gap: 16px;
}
.ad .badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.22); align-self: flex-start;
}
.ad .txt { flex: 1; }
.ad .txt b { display: block; font-size: 17px; margin: 4px 0 2px; }
.ad .txt span { font-size: 13px; opacity: .9; }

/* ---------- 一覧・管理画面 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card .meta { font-size: 13px; color: var(--sub); }
.kpi { font-size: 30px; font-weight: 700; }

.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.tag.done { background: #e8f5ec; color: var(--ok); }
.tag.todo { background: #fde8e8; color: var(--warn); }
.tag.draft { background: #eceff3; color: var(--sub); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar > div { min-width: 160px; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 14px; }
.tabs a {
  padding: 10px 18px; text-decoration: none; color: var(--sub);
  font-weight: 700; border-radius: 8px 8px 0 0;
}
.tabs a.on { background: #fff; color: var(--accent); border: 2px solid var(--line); border-bottom: 2px solid #fff; margin-bottom: -2px; }

/* 署名 */
.sign {
  height: 56px; border: 1px dashed var(--line-strong); border-radius: 6px;
  background: #fff; display: flex; align-items: center; justify-content: center;
  color: var(--sub); font-size: 13px; cursor: pointer;
}
.sign.signed { font-family: "Yu Mincho", serif; font-size: 20px; color: #123; border-style: solid; }

.legend { font-size: 12px; color: var(--sub); }
.legend table { margin-top: 6px; }
.legend th, .legend td { padding: 4px 6px; font-size: 12px; }

.hint { font-size: 12px; color: var(--sub); margin-top: 4px; }

/* ---------- ログイン ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(160deg, #10375e, #1d6fb8);
}
.login-box {
  width: 100%; max-width: 420px; background: #fff;
  border-radius: 16px; padding: 30px 28px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.login-box .lead { margin: 0 0 22px; font-size: 13px; color: var(--sub); }
.login-box label { margin-top: 14px; }
.login-box .btn { width: 100%; margin-top: 22px; }
.error {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px;
  background: #fde8e8; color: var(--warn); font-size: 14px;
}
.pw-out {
  margin-top: 10px; padding: 12px 14px; border-radius: 8px;
  background: #e8f5ec; border: 1px solid #9ed3b0;
  font-family: Consolas, monospace; font-size: 18px; letter-spacing: .05em;
}

/* ---------- ダイアログ（追加・編集用） ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(20,25,32,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal {
  background: #fff; border-radius: 14px; padding: 24px;
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  box-shadow: 0 16px 50px rgba(0,0,0,.3);
}
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal .sub { margin: 0 0 18px; font-size: 13px; color: var(--sub); }
.modal .row { margin-bottom: 12px; }
.modal .actions { margin-top: 20px; }

.danger { color: var(--warn); border-color: #e6a5a5; }
.danger-zone {
  margin-top: 26px; padding: 16px; border: 1px solid #e6a5a5;
  border-radius: 10px; background: #fdf6f6;
}
.danger-zone h3 { margin: 0 0 6px; font-size: 15px; color: var(--warn); }

.ok-box {
  margin-top: 12px; padding: 12px 14px; border-radius: 8px;
  background: #e8f5ec; border: 1px solid #9ed3b0; font-size: 14px;
}
.copy-line {
  display: flex; gap: 8px; align-items: center; margin-top: 8px;
  font-family: Consolas, monospace; font-size: 14px; word-break: break-all;
}
.chk-row { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.chk-row input { width: 20px; height: 20px; accent-color: var(--accent); }

/* 署名パッド */
.sig-pad {
  width: 100%; height: 180px; touch-action: none;
  border: 2px dashed var(--line-strong); border-radius: 10px;
  background: #fff; display: block;
}
.sign img { max-height: 46px; max-width: 100%; display: block; margin: 0 auto; }
.sign.signed { border-style: solid; padding: 2px; }

/* ================= 印刷（元請へ提出するPDF） =================
   画面のヘッダー・ボタン・タブは紙に出さない。
   紙の様式に近い体裁で1枚に収める。 */
@media print {
  @page { size: A4 landscape; margin: 8mm; }

  html, body { background: #fff !important; font-size: 10.5pt; }

  /* 画面のための部品は消す */
  .appbar, .tabs, .toolbar, .actions, .btn, .hint, .mock-note,
  .modal-bg, .back, .ad, #pwOut, .foot { display: none !important; }

  .wrap { max-width: none; margin: 0; padding: 0; }

  .paper {
    border: 1.5pt solid #000; padding: 6mm;
    box-shadow: none; break-inside: avoid;
  }
  .paper-title { font-size: 16pt; margin: 0 0 4mm; letter-spacing: .25em; }

  .sec { border: 0.8pt solid #000; margin-bottom: 2.5mm; break-inside: avoid; }
  .sec > h2 {
    background: #eee !important; border-bottom: 0.8pt solid #000;
    font-size: 10pt; padding: 1.2mm 2mm;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .sec > .body { padding: 2mm; }

  table { border-collapse: collapse; width: 100%; }
  th, td { border: 0.6pt solid #000; padding: 1.2mm 1.8mm; font-size: 9.5pt; }
  th {
    background: #eee !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }

  /* 入力欄は枠線を消して、書かれた文字だけが残るようにする */
  input, textarea, select {
    border: 0 !important; background: transparent !important;
    padding: 0 !important; font-size: 9.5pt; color: #000 !important;
    -webkit-appearance: none; appearance: none;
  }
  textarea { resize: none; overflow: visible; height: auto !important; }
  select { background-image: none !important; }

  /* 危険度の色は薄い網掛けに落として、白黒でも読めるようにする */
  .rank, .calc {
    background: #f2f2f2 !important; color: #000 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }

  /* チェック項目は □ / ■ で表す */
  .checks { display: block; }
  .chk {
    display: inline-block; border: 0; padding: 0 3mm 0 0;
    min-height: 0; font-size: 9.5pt; background: transparent !important;
  }
  .chk input { display: none; }
  .chk::before { content: '☐ '; }
  .chk:has(input:checked)::before { content: '☑ '; font-weight: 700; }

  .sign { border: 0.6pt solid #000; height: auto; min-height: 10mm; }
  .sign img { max-height: 9mm; }
  .legend { font-size: 8pt; }

  a { text-decoration: none; color: #000; }
}

/* 写真の添付（任意） */
.photo-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.photo-actions .hint { margin: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo-item {
  position: relative; aspect-ratio: 4/3; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: #f4f6f9;
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-item.photo-loading {
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--sub); border-style: dashed;
}
.photo-del {
  position: absolute; top: 4px; right: 4px; width: 30px; height: 30px;
  border: 0; border-radius: 50%; background: rgba(20,25,32,.72); color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer;
}
/* 提出済みの表示 */
.photo-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.photo-view a { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.photo-view img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }

@media print {
  .photo-actions, .photo-del { display: none !important; }
  .photo-grid, .photo-view { grid-template-columns: repeat(3, 1fr); gap: 3mm; }
  .photo-item, .photo-view a { border: 0.6pt solid #000; break-inside: avoid; }
}
