/* ============================================================
   Jリース申込書 自動転記 — 画像オーバーレイ方式
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --form-w: 380px;
  --top-h: 52px;
  --primary: #1a5fa8;
  --primary-dk: #134a87;
  --primary-lt: #e8f0fc;
  --border: #d0d5dd;
  --bg: #f0f4fa;
  --white: #fff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --red: #e74c3c;
  --radius: 7px;
  --shadow: 0 1px 4px rgba(0,0,0,.09);
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========== トップバー =========== */
#jf-topbar {
  height: var(--top-h);
  background: linear-gradient(90deg, #0f2d5c, #1a5fa8);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  flex-shrink: 0;
}
.jf-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 5px;
  transition: background .18s;
  white-space: nowrap;
}
.jf-back-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.jf-topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 700;
  flex: 1;
}
.jf-topbar-title i { color: #7eb8f7; }
.jf-topbar-actions { display: flex; gap: 8px; }

/* =========== ボタン =========== */
.jf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .18s;
  font-family: inherit;
  white-space: nowrap;
}
.jf-btn:active { transform: scale(.97); }
.jf-btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.jf-btn-primary:hover { background: var(--primary-dk); }
.jf-btn-outline  { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.4); }
.jf-btn-outline:hover { background: rgba(255,255,255,.2); }
.jf-btn-print    { background: #27ae60; color: #fff; border-color: #27ae60; }
.jf-btn-print:hover { background: #1e8449; }
.jf-btn-excel    { background: #1e6e3c; color: #fff; border-color: #1e6e3c; }
.jf-btn-excel:hover { background: #155229; }
.jf-btn-excel i  { color: #a8d8a8; }
.jf-btn-block    { width: 100%; justify-content: center; padding: 11px; font-size: 13.5px; }

/* =========== 2カラムレイアウト =========== */
#jf-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--top-h));
}

/* =========== 左フォームパネル =========== */
#jf-form-panel {
  width: var(--form-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.jf-panel-header {
  padding: 11px 16px;
  background: #f5f7ff;
  border-bottom: 2px solid var(--primary);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.jf-panel-sub {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
  margin-left: auto;
}
.jf-form-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 20px;
}

/* セクション */
.jf-section {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.jf-sec-title {
  background: #1a3a6b;
  color: #fff;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
}
.jf-sec-num {
  width: 18px; height: 18px;
  background: rgba(255,255,255,.22);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.jf-field-row {
  display: flex;
  gap: 8px;
  padding: 8px 12px 0;
}
.jf-field-row:last-child { padding-bottom: 10px; }

.jf-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.jf-field.jf-full { flex: 100%; }
.jf-field label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
}
.req {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 8.5px;
  padding: 1px 3px;
  border-radius: 2px;
  margin-left: 3px;
  vertical-align: middle;
}
.jf-input {
  width: 100%;
  padding: 6px 9px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .17s, box-shadow .17s;
}
.jf-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,95,168,.1);
}
.jf-select {
  width: 100%;
  padding: 6px 9px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}
.jf-select:focus { outline: none; border-color: var(--primary); }

.jf-radios {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
}
.jf-radios label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
}
.jf-radios input { accent-color: var(--primary); }

.jf-save-area { padding: 6px 0 4px; }

/* =========== 右プレビューパネル =========== */
#jf-preview-panel {
  flex: 1;
  background: #cbd2dc;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.jf-preview-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 20px;
  display: flex;
  justify-content: center;
}

/* =========== 帳票ラッパー（画像＋オーバーレイ） =========== */
.jf-sheet-wrap {
  position: relative;
  /* 表示幅は 760px 固定（スクロールで対応） */
  width: 760px;
  flex-shrink: 0;
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
}

/* ベース画像 */
.jf-base-img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

/* =========== オーバーレイ共通 =========== */
.ov {
  position: absolute;
  display: flex;
  align-items: center;
  /* フォントサイズは % で指定（画像幅760px基準） */
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 500;
  color: #0a1a3e;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1;
  padding: 0 2px;
  pointer-events: none;
  transition: background .15s;
}

/* 名前フィールド（やや大きく太く） */
.ov.ov-name {
  font-weight: 700;
  color: #000;
}

/* 右寄せ（金額欄） */
.ov.ov-right {
  justify-content: flex-end;
}

/* 合計金額強調 */
.ov.ov-total {
  color: #1a5fa8;
  font-weight: 700;
}

/* チェックマーク */
.ov.ov-check {
  justify-content: center;
  font-size: 1.8% !important;
  color: #1a3a6b;
  font-weight: 900;
}

/* 入力時ハイライト */
@keyframes ovFlash {
  0%   { background: rgba(255, 245, 120, 0.75); }
  100% { background: transparent; }
}
.ov.flash { animation: ovFlash .55s ease forwards; }

/* =========== トースト =========== */
#jf-toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.jf-toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #1e6640;
  color: #fff;
  padding: 11px 17px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,.15);
  font-size: 13px;
  font-weight: 500;
  min-width: 230px;
  animation: toastIn .28s ease;
}
.jf-toast.error { background: #a93226; }
.jf-toast.info  { background: #1a5fa8; }
@keyframes toastIn  { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(8px); } }

/* =========== 印刷 =========== */
@media print {
  #jf-topbar, #jf-form-panel, .jf-panel-header { display: none !important; }
  * { overflow: visible !important; }
  #jf-layout { display: block; height: auto; }
  #jf-preview-panel { background: #fff; }
  .jf-preview-scroll { padding: 0; }
  .jf-sheet-wrap { width: 100%; box-shadow: none; }
}

/* =========== レスポンシブ =========== */
@media (max-width: 860px) {
  :root { --form-w: 100%; }
  #jf-layout { flex-direction: column; height: auto; overflow: visible; }
  #jf-form-panel { width: 100%; border-right: none; border-bottom: 2px solid var(--primary); max-height: 55vh; }
  #jf-preview-panel { min-height: 80vh; }
  .jf-sheet-wrap { width: 100%; min-width: 340px; }
}
