// =====================================================
// トップページ(LP型) — lp1.nihon-planner.com の構成・見た目を参考に
// 令和財託の実データで構成。Header / Footer / 下層ページは app.jsx のまま。
// =====================================================

const lpIcons = {
  phone: (
    <svg viewBox="0 0 24 24" width="28" height="28" fill="currentColor" aria-hidden="true">
      <path d="M6.6 10.8a15.1 15.1 0 0 0 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1A17 17 0 0 1 3 4c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.3 0 .7-.2 1l-2.3 2.2z" />
    </svg>
  ),
  calendar: (
    <svg viewBox="0 0 64 64" width="64" height="64" fill="none" aria-hidden="true">
      <rect x="8" y="12" width="48" height="44" rx="6" fill="#fff" stroke="#0b58a5" strokeWidth="3" />
      <rect x="8" y="12" width="48" height="12" rx="6" fill="#0b58a5" />
      <line x1="20" y1="6" x2="20" y2="18" stroke="#0b58a5" strokeWidth="4" strokeLinecap="round" />
      <line x1="44" y1="6" x2="44" y2="18" stroke="#0b58a5" strokeWidth="4" strokeLinecap="round" />
      <circle cx="40" cy="42" r="10" fill="#ffb400" />
      <path d="M40 36v6l4 3" stroke="#fff" strokeWidth="3" strokeLinecap="round" />
      <rect x="16" y="30" width="8" height="6" rx="1" fill="#bfe0f5" />
      <rect x="16" y="40" width="8" height="6" rx="1" fill="#bfe0f5" />
    </svg>
  ),
  bank: (
    <svg viewBox="0 0 64 64" width="64" height="64" fill="none" aria-hidden="true">
      <path d="M8 24 32 10l24 14z" fill="#0b58a5" />
      <rect x="12" y="26" width="40" height="4" fill="#0b58a5" />
      {[16, 26, 36, 46].map(x => <rect key={x} x={x - 2} y="32" width="6" height="16" fill="#bfe0f5" stroke="#0b58a5" strokeWidth="2" />)}
      <rect x="8" y="50" width="48" height="6" rx="1" fill="#0b58a5" />
      <circle cx="50" cy="16" r="9" fill="#ffb400" />
      <path d="M50 11v6M50 20v1" stroke="#fff" strokeWidth="3" strokeLinecap="round" />
    </svg>
  ),
  coins: (
    <svg viewBox="0 0 64 64" width="64" height="64" fill="none" aria-hidden="true">
      <rect x="6" y="14" width="40" height="24" rx="3" fill="#bfe0f5" stroke="#0b58a5" strokeWidth="3" />
      <circle cx="26" cy="26" r="6" stroke="#0b58a5" strokeWidth="3" />
      {[0, 1, 2, 3].map(i => <ellipse key={i} cx="44" cy={54 - i * 6} rx="14" ry="4.5" fill="#ffb400" stroke="#d88f00" strokeWidth="2" />)}
    </svg>
  ),
  yen: (
    <svg viewBox="0 0 64 64" width="72" height="72" fill="none" aria-hidden="true">
      <circle cx="32" cy="32" r="26" fill="#e5f2fb" />
      <path d="M20 44 32 20l12 24" stroke="#0b58a5" strokeWidth="4" strokeLinecap="round" strokeLinejoin="round" fill="none" />
      <path d="M14 46h36" stroke="#ffb400" strokeWidth="4" strokeLinecap="round" />
      <path d="M44 16l6 6-6 6" stroke="#ffb400" strokeWidth="4" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  ),
  check: (
    <svg viewBox="0 0 64 64" width="72" height="72" fill="none" aria-hidden="true">
      <circle cx="32" cy="32" r="26" fill="#e5f2fb" />
      <rect x="20" y="14" width="24" height="34" rx="3" fill="#fff" stroke="#0b58a5" strokeWidth="3" />
      <path d="M25 30l5 5 9-10" stroke="#ffb400" strokeWidth="4" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M25 41h14" stroke="#bfe0f5" strokeWidth="3" strokeLinecap="round" />
    </svg>
  ),
  people: (
    <svg viewBox="0 0 64 64" width="72" height="72" fill="none" aria-hidden="true">
      <circle cx="32" cy="32" r="26" fill="#e5f2fb" />
      <circle cx="24" cy="25" r="6" fill="#0b58a5" />
      <path d="M13 46c1-7 5-11 11-11s10 4 11 11z" fill="#0b58a5" />
      <circle cx="41" cy="27" r="5" fill="#ffb400" />
      <path d="M33 46c1-6 4-9 8-9s7 3 8 9z" fill="#ffb400" />
    </svg>
  ),
  line: (
    <svg viewBox="0 0 24 24" width="26" height="26" fill="currentColor" aria-hidden="true">
      <path d="M12 2C6.48 2 2 5.73 2 10.3c0 4.1 3.56 7.53 8.37 8.18.33.07.77.22.88.5.1.26.07.66.03.92l-.14.86c-.04.26-.2 1 .88.55 1.08-.46 5.82-3.43 7.94-5.87C21.3 13.87 22 12.15 22 10.3 22 5.73 17.52 2 12 2z" />
    </svg>
  ),
};

// ===== 追従バナー =====
// PC: 画面右端に縦型で追従する「電話」「LINE」ボタン
// スマホ: 画面下部に固定表示される「電話」「LINE」ボタン
// ※トップページ(LP型)のみに表示。公式LINEのURLが未発行の間は
//   COMPANY.lineUrl が '#' のままでも動作するが、クリック時にアラートで案内する。
function LpFollowBar({ COMPANY }) {
  const handleLineClick = (e) => {
    if (!COMPANY.lineUrl || COMPANY.lineUrl === '#') {
      e.preventDefault();
      alert('只今、公式LINEの準備中です。お急ぎの場合はお電話にてご連絡ください。');
    }
  };
  return (
    <>
      {/* PC用: 画面右端に追従する縦型ボタン */}
      <div className="lp-follow-pc" aria-label="お問い合わせ導線">
        <a className="lp-follow-pc-btn lp-follow-pc-tel" href={'tel:' + COMPANY.tel.replace(/-/g, '')}>
          {lpIcons.phone}
          <span>電話</span>
        </a>
        <a
          className="lp-follow-pc-btn lp-follow-pc-line"
          href={COMPANY.lineUrl || '#'}
          target={COMPANY.lineUrl && COMPANY.lineUrl !== '#' ? '_blank' : undefined}
          rel="noopener noreferrer"
          onClick={handleLineClick}
        >
          {lpIcons.line}
          <span>LINE</span>
        </a>
      </div>

      {/* スマホ用: 画面下部に固定する横型バー */}
      <div className="lp-follow-mobile" role="navigation" aria-label="お問い合わせ導線">
        <a className="lp-follow-mobile-btn lp-follow-mobile-tel" href={'tel:' + COMPANY.tel.replace(/-/g, '')}>
          {lpIcons.phone}
          <span>電話で相談</span>
        </a>
        <a
          className="lp-follow-mobile-btn lp-follow-mobile-line"
          href={COMPANY.lineUrl || '#'}
          target={COMPANY.lineUrl && COMPANY.lineUrl !== '#' ? '_blank' : undefined}
          rel="noopener noreferrer"
          onClick={handleLineClick}
        >
          {lpIcons.line}
          <span>公式LINE</span>
        </a>
      </div>
    </>
  );
}

function LpCtaButtons({ setPage, COMPANY }) {
  return (
    <div className="lp-cta-row">
      <button className="lp-cta-orange" onClick={() => setPage('consult')}>
        <span>まずは無料で相談・査定</span>
        <span className="lp-cta-tri">▶</span>
      </button>
      <a className="lp-cta-blue" href={'tel:' + COMPANY.tel.replace(/-/g, '')}>
        {lpIcons.phone}
        <span className="lp-cta-tel">
          <span className="lp-cta-tel-num">{COMPANY.tel}</span>
          <span className="lp-cta-tel-hours">{COMPANY.hours}</span>
        </span>
      </a>
    </div>
  );
}

function LpHead({ en, children, light }) {
  return (
    <div className={`lp-head${light ? ' lp-head-light' : ''}`}>
      {en && <div className="lp-head-en">{en}</div>}
      <h2 className="lp-head-title">{children}</h2>
    </div>
  );
}

function LpStepBadge({ n }) {
  const id = 'lpArc' + n;
  return (
    <svg className="lp-step-badge" viewBox="0 0 220 220" aria-label={'STEP ' + n}>
      <defs><path id={id} d="M 40 150 A 84 84 0 1 1 190 150" /></defs>
      <path d="M 40 150 A 84 84 0 1 1 190 150" fill="none" stroke="#0b58a5" strokeWidth="2" />
      <text fontSize="22" fill="#0b58a5" fontWeight="500" letterSpacing="1">
        <textPath href={'#' + id} startOffset="57%">Flow of Factoring</textPath>
      </text>
      <circle cx="110" cy="114" r="70" fill="#0b58a5" />
      <text x="110" y="96" textAnchor="middle" fontSize="24" fontWeight="700" fill="#fff" letterSpacing="1">STEP</text>
      <text x="110" y="152" textAnchor="middle" fontSize="54" fontWeight="500" fill="#fff">{String(n).padStart(2, '0')}</text>
    </svg>
  );
}

function LpFaq({ items }) {
  const [open, setOpen] = React.useState(0);
  const [isMobile, setIsMobile] = React.useState(false);
  const [expanded, setExpanded] = React.useState(false);
  React.useEffect(() => {
    const check = () => setIsMobile(window.innerWidth <= 768);
    check();
    window.addEventListener('resize', check);
    return () => window.removeEventListener('resize', check);
  }, []);
  const MOBILE_VISIBLE = 5;
  const visibleItems = (isMobile && !expanded) ? items.slice(0, MOBILE_VISIBLE) : items;
  return (
    <div className="lp-faq">
      {visibleItems.map((f, i) => (
        <div key={i} className={`lp-faq-item${open === i ? ' open' : ''}`}>
          <button className="lp-faq-q" onClick={() => setOpen(open === i ? -1 : i)} aria-expanded={open === i}>
            <span className="lp-faq-mark">Q</span>
            <span className="lp-faq-q-text">{f.q}</span>
            <span className="lp-faq-toggle">{open === i ? '−' : '+'}</span>
          </button>
          {open === i && (
            <div className="lp-faq-a">
              <span className="lp-faq-mark lp-faq-mark-a">A</span>
              <span dangerouslySetInnerHTML={{ __html: f.a }} />
            </div>
          )}
        </div>
      ))}
      {isMobile && !expanded && items.length > MOBILE_VISIBLE && (
        <button type="button" className="lp-faq-more" onClick={() => setExpanded(true)}>
          <span>よくあるご質問をもっと見る（残り{items.length - MOBILE_VISIBLE}件）</span>
          <span className="lp-faq-more-arrow">▼</span>
        </button>
      )}
    </div>
  );
}

function LpForm({ setPage, setConsultEntrySubmissionId }) {
  // 無料相談ページ(STEP1)と全く同じ入力項目・送信先に統一。
  // ここで送信すると /api/consult/step1 にデータが入り、無料相談ページのSTEP2(書類提出)へ
  // そのまま進めるようになる(二重入力をなくし、書類提出までのスピードを上げるため)。
  const [form, setForm] = React.useState({
    company: '', revenue: '', ceo: '', address: '', tel: '', email: '',
    desiredAmount: '', desiredTiming: '', note: '',
  });
  const [submissionId, setSubmissionId] = React.useState(null);
  const [status, setStatus] = React.useState('idle'); // idle | sending | done | error
  const [errorMsg, setErrorMsg] = React.useState('');
  const update = (k, v) => setForm(s => ({ ...s, [k]: v }));

  const handleSubmit = async (e) => {
    e.preventDefault();
    setStatus('sending');
    setErrorMsg('');
    try {
      const res = await fetch('/api/consult/step1', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(form)
      });
      const data = await res.json();
      if (!res.ok || !data.ok) {
        throw new Error(data.error || '送信に失敗しました。');
      }
      setSubmissionId(data.submissionId);
      setStatus('done');
    } catch (err) {
      setStatus('error');
      setErrorMsg(err.message || '送信中にエラーが発生しました。時間をおいて再度お試しください。');
    }
  };

  const goToDocumentSubmit = () => {
    if (setConsultEntrySubmissionId) setConsultEntrySubmissionId(submissionId);
    if (setPage) setPage('consult');
  };

  if (status === 'done') {
    return (
      <div className="lp-form-done">
        <div className="lp-form-done-title">ご入力ありがとうございます</div>
        <p>ファクタリングによる資金調達のご相談を承りました。<br/>引き続き必要書類をご提出いただくと、審査・入金までのスピードが早まります。</p>
        <button type="button" className="lp-cta-orange lp-form-submit lp-form-done-cta" onClick={goToDocumentSubmit} style={{ marginTop: 20 }}>
          <span>今すぐ書類を提出して2時間以内の入金を目指す</span><span className="lp-cta-tri">▶</span>
        </button>
        <p className="lp-form-note" style={{ marginTop: 12 }}>担当者より、営業時間内に折り返しご連絡いたします。お急ぎの場合はお電話でご相談ください。</p>
      </div>
    );
  }
  return (
    <form className="lp-form" onSubmit={handleSubmit}>
      <label className="lp-form-row">
        <span className="lp-form-label">会社名(屋号)<em>必須</em></span>
        <input type="text" placeholder="例)令和財託株式会社" required value={form.company} onChange={e => update('company', e.target.value)} />
      </label>
      <label className="lp-form-row">
        <span className="lp-form-label">売上月商<em>必須</em></span>
        <select required value={form.revenue} onChange={e => update('revenue', e.target.value)}>
          <option value="" disabled>選択してください</option>
          <option>〜100万円</option>
          <option>100〜500万円</option>
          <option>500〜1,000万円</option>
          <option>1,000〜5,000万円</option>
          <option>5,000万円〜1億円</option>
          <option>1億円〜</option>
        </select>
      </label>
      <label className="lp-form-row">
        <span className="lp-form-label">代表者様お名前<em>必須</em></span>
        <input type="text" placeholder="例)山田 太郎" required value={form.ceo} onChange={e => update('ceo', e.target.value)} />
      </label>
      <label className="lp-form-row">
        <span className="lp-form-label">所在地(住所)<em>必須</em></span>
        <input type="text" placeholder="例)東京都中央区日本橋小網町8-2" required value={form.address} onChange={e => update('address', e.target.value)} />
      </label>
      <label className="lp-form-row">
        <span className="lp-form-label">電話番号<em>必須</em></span>
        <input type="tel" placeholder="例)03-1234-5678" required value={form.tel} onChange={e => update('tel', e.target.value)} />
      </label>
      <label className="lp-form-row">
        <span className="lp-form-label">メールアドレス<em>必須</em></span>
        <input type="email" placeholder="例)info@example.co.jp" required value={form.email} onChange={e => update('email', e.target.value)} />
      </label>
      <label className="lp-form-row">
        <span className="lp-form-label">ご希望調達金額<span className="lp-form-opt">任意</span></span>
        <select value={form.desiredAmount} onChange={e => update('desiredAmount', e.target.value)}>
          <option value="">未選択</option>
          <option>〜100万円</option>
          <option>100〜500万円</option>
          <option>500〜1,000万円</option>
          <option>1,000〜5,000万円</option>
          <option>5,000万円〜</option>
        </select>
      </label>
      <label className="lp-form-row">
        <span className="lp-form-label">ご希望入金時期<span className="lp-form-opt">任意</span></span>
        <select value={form.desiredTiming} onChange={e => update('desiredTiming', e.target.value)}>
          <option value="">未選択</option>
          <option>本日中</option>
          <option>2〜3日以内</option>
          <option>1週間以内</option>
          <option>相談したい</option>
        </select>
      </label>
      <label className="lp-form-row">
        <span className="lp-form-label">ご相談内容<span className="lp-form-opt">任意</span></span>
        <textarea rows="4" placeholder="現在の資金繰りの状況、他社利用中かどうか、その他ご質問など" value={form.note} onChange={e => update('note', e.target.value)} />
      </label>
      {status === 'error' && <p className="lp-form-error">{errorMsg}</p>}
      <button type="submit" className="lp-cta-orange lp-form-submit" disabled={status === 'sending'}>
        <span>{status === 'sending' ? '送信中...' : '無料で査定を申し込む'}</span><span className="lp-cta-tri">▶</span>
      </button>
      <p className="lp-form-note">※ご入力いただいた情報は、お問い合わせへの回答のみに利用いたします。</p>
    </form>
  );
}

function LPTop({ setPage, setBlogId, setConsultEntrySubmissionId, COMPANY, FAQ, CASES, BlogSection, CasesSection: CasesFromProps }) {
  const CasesSection = CasesFromProps || window.CasesSection;
  const featured = [CASES[0], CASES[5] || CASES[1]];
  const voices = CASES.filter(c => !featured.includes(c)).slice(0, 4);
  const headline = (html) => {
    const m = /<strong>(.*?)<\/strong>/.exec(html || '');
    return m ? m[1] : '';
  };

  return (
    <div className="lp">
      <LpFollowBar COMPANY={COMPANY} />
      {/* ===== HERO ===== */}
      <section className="lp-hero">
        <div className="lp-hero-stripes" />
        <div className="lp-hero-photo" style={{ backgroundImage: 'url(/assets/handshake.jpg)' }} role="img" aria-label="担当者がお客様の資金調達について相談を受ける様子" />
        <div className="lp-container lp-hero-inner">
          <div className="lp-hero-tags">
            <span className="lp-tag">中小企業</span><span className="lp-tag">個人事業主</span>
            <span className="lp-hero-tags-break" />
            <span className="lp-tag">赤字経営・新規事業主</span>
            <span className="lp-hero-tags-tail">の<b>資金調達</b>をサポート</span>
          </div>
          <h1 className="lp-hero-h1">
            <span className="lp-hero-pre">お手元の請求書を</span>
            <span className="lp-hero-main">
              <span className="lp-hero-circle">最短</span>
              <span className="lp-hero-two">2</span>
              <span className="lp-hero-words">
                <span className="lp-hero-w1">時間<small>で</small></span>
                <span className="lp-hero-w2">事業資金<small>に</small></span>
              </span>
            </span>
            <span className="lp-hero-sub"><b>最短30分</b>で買取可能額を査定</span>
          </h1>
          <div className="lp-hero-stats">
            {[['手数料', '1', '%〜'], ['必要書類', '3', '点のみ'], ['スマホ完結', 'WEB', '契約'], ['審査通過率', '98', '%']].map(([l, n, u]) => (
              <div key={l} className="lp-hero-stat">
                <div className="lp-hero-stat-label">{l}</div>
                <div className="lp-hero-stat-val"><span className="lp-hero-stat-num">{n}</span><span className="lp-hero-stat-unit">{u}</span></div>
              </div>
            ))}
          </div>
        </div>
      </section>

      <section className="lp-cta-band">
        <div className="lp-container"><LpCtaButtons setPage={setPage} COMPANY={COMPANY} /></div>
      </section>

      {/* ===== NAVY BAND ===== */}
      <section className="lp-navy">
        <div className="lp-container">
          <p className="lp-navy-lead">「次の支払いに間に合わない」と諦める前に</p>
          <p className="lp-navy-sub">資金繰りに悩む、すべての経営者様へ</p>
          <h2 className="lp-navy-title">
            <span>ファクタリングで</span>
            <span className="lp-navy-tiles">{['最', '短', '即', '日', 'の'].map((c, i) => <i key={i}>{c}</i>)}</span>
            <span>資金調達</span>
          </h2>
          <div className="lp-navy-stats">
            {[['手数料', '1', '%〜'], ['必要書類', '3', '点のみ'], ['審査通過率', '98', '%'], ['累計買取額', '5', '億円']].map(([l, n, u]) => (
              <div key={l} className="lp-navy-stat">
                <div className="lp-navy-stat-label">{l}</div>
                <div className="lp-navy-stat-val"><span className="lp-navy-stat-num">{n}</span><span className="lp-navy-stat-unit">{u}</span></div>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ===== CONSULT POINTS ===== */}
      <section className="lp-sec lp-sec-pale">
        <div className="lp-container">
          <LpHead>資金調達に関するお悩み、<br />まずはお気軽にご相談ください</LpHead>
          <div className="lp-points">
            <div className="lp-point"><span className="lp-point-label">ご利用対象</span><strong>法人・<br />個人事業主</strong></div>
            <div className="lp-point"><span className="lp-point-label">柔軟な審査</span><strong>赤字・税金滞納中でも<br />ご相談可能</strong></div>
            <div className="lp-point"><span className="lp-point-label">資金化まで</span><strong>最短<em>2</em>時間</strong></div>
          </div>
          <LpCtaButtons setPage={setPage} COMPANY={COMPANY} />
        </div>
      </section>

      {/* ===== WORRIES ===== */}
      <section className="lp-sec">
        <div className="lp-container">
          <LpHead>このような<span className="lp-quote">“<b>お悩み</b>”</span>も<br className="lp-sp" />まずはお気軽にご相談ください</LpHead>
          <div className="lp-worries">
            {[
              [lpIcons.calendar, '今日・明日の支払いに', '間に合わせたい'],
              [lpIcons.bank, '銀行融資の実行を', '待つ時間がない'],
              [lpIcons.coins, '高額な売掛金を', '資金化したい'],
            ].map(([ic, a, b], i) => (
              <div key={i} className="lp-worry">
                <div className="lp-worry-ic">{ic}</div>
                <p>{a}<br /><b>{b}</b></p>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ===== REASONS ===== */}
      <section className="lp-sec lp-sec-pale">
        <div className="lp-container">
          <div className="lp-reason-head">
            <div className="lp-reason-pre"><b>令和財託</b>が</div>
            <h2 className="lp-head-title">多くの経営者様に<br />選ばれる理由</h2>
          </div>
          <div className="lp-reasons">
            {[
              { t: '売買手数料', n: '1', u: '%〜', ic: lpIcons.yen, d: '手数料は1%から。売掛金の内容やご希望の資金化時期を確認したうえで、条件をわかりやすくご提示します。まずは無料でお見積りをご相談ください。' },
              { t: '審査通過率', n: '98', u: '%', ic: lpIcons.check, d: '赤字決算・税金滞納・創業間もない方でも、売掛先の信用力を重視した独自基準で審査します。他社で断られた方もご相談ください。' },
              { t: '累計取引件数', n: '3,000', u: '件+', ic: lpIcons.people, d: '建設業・運送業・IT・個人事業主など幅広いお客様をご支援。自社で内装工事を運営しているため、建設業の資金繰りにも深く対応できます。' },
            ].map((r, i) => (
              <div key={i} className="lp-reason">
                <div className="lp-reason-no">POINT {String(i + 1).padStart(2, '0')}</div>
                <h3>{r.t}</h3>
                <div className="lp-reason-num"><strong>{r.n}</strong><span>{r.u}</span></div>
                <div className="lp-reason-ic">{r.ic}</div>
                <p>{r.d}</p>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ===== COMPARISON ===== */}
      <section className="lp-sec">
        <div className="lp-container">
          <LpHead en="COMPARISON">令和財託と<br className="lp-sp" />他の資金調達方法の比較</LpHead>
          <p className="lp-scroll-hint">横にスクロールできます →</p>
          <div className="lp-compare-wrap">
            <table className="lp-compare">
              <thead>
                <tr>
                  <th className="lp-compare-blank" />
                  <th className="lp-compare-us">令和財託</th>
                  <th>一般的な<br />ファクタリング会社</th>
                  <th>銀行融資</th>
                </tr>
              </thead>
              <tbody>
                {[
                  ['振込スピード', <><b>最短2時間</b></>, '最短翌日〜', '2週間〜1ヶ月'],
                  ['手数料・金利', <><b>1</b>%〜</>, '2〜10%程度', '年1〜3%程度'],
                  ['必要書類', <>請求書<br />通帳(3ヶ月分)<br />本人確認書類</>, '4〜6点程度', '10点以上'],
                  ['担保・保証人', <b>不要</b>, '不要', '必要な場合あり'],
                  ['対応エリア', <>全国・<b>オンライン</b></>, '会社により異なる', '取引銀行の営業エリア'],
                  ['建設業への理解', <>自社で<b>内装工事</b>を運営</>, '会社により異なる', '—'],
                ].map(([label, us, a, b], i) => (
                  <tr key={i}>
                    <th>{label}</th>
                    <td className="lp-compare-us">{us}</td>
                    <td>{a}</td>
                    <td>{b}</td>
                  </tr>
                ))}
              </tbody>
            </table>
          </div>
          <p className="lp-note">※一般的なファクタリング会社・銀行融資の数値は一般的な目安です。</p>
        </div>
      </section>

      {/* ===== FLOW ===== */}
      <section className="lp-sec lp-sec-pale">
        <div className="lp-container">
          <LpHead en="FLOW">ファクタリングご利用の流れ</LpHead>
          <ol className="lp-flow">
            {[
              ['無料相談・お申込み', 'WEBフォームまたはお電話から、資金化をご希望の売掛金についてご相談ください。'],
              ['必要書類のご提出・お見積り', '請求書・通帳(3ヶ月分)・本人確認書類をご提出いただき、最短30分で買取条件をご案内します。'],
              ['ご契約・お振込み', 'お見積りにご納得いただいた後にオンラインでご契約。最短2時間で指定口座へお振込みします。'],
            ].map(([t, d], i) => (
              <li key={i} className="lp-flow-step">
                <LpStepBadge n={i + 1} />
                <h3>{t}</h3>
                <p>{d}</p>
              </li>
            ))}
          </ol>
        </div>
      </section>

      {/* ===== CASE(従来の導入事例カルーセルをそのまま使用) ===== */}
      {CasesSection && <div className="lp-orig-cases"><CasesSection /></div>}

      {/* ===== EXPERT ===== */}
      <section className="lp-sec lp-sec-pale">
        <div className="lp-container">
          <LpHead en="EXPERT TEAM">金融と現場を知る担当者が対応</LpHead>
          <div className="lp-expert-hero">
            <div className="lp-expert-hero-small">ファクタリング × 建設を両輪で運営</div>
            <div className="lp-expert-hero-big">日本で唯一の資金調達パートナー</div>
            <p>金融と建設、両方の現場を知る担当者が、お申込みからご契約まで一貫して対応いたします。</p>
          </div>
          <ol className="lp-expert">
            {[
              ['状況に応じた資金調達をご提案', '売掛金の資金化だけでなく、資金繰りや今後の事業計画を踏まえ、最適な選択肢を一緒に検討します。'],
              ['建設業の商習慣を理解した審査', '出来高払い・下請け構造・工期を熟知しているため、注文書段階での資金化にも柔軟に対応します。'],
              ['契約後も資金繰りのご相談が可能', 'ご契約後も経営・資金繰りのご相談を継続して承ります。強引な営業やしつこいご連絡は一切いたしません。'],
            ].map(([t, d], i) => (
              <li key={i}>
                <span className="lp-expert-no">{String(i + 1).padStart(2, '0')}</span>
                <h3>{t}</h3>
                <p>{d}</p>
              </li>
            ))}
          </ol>
          <div className="lp-expert-cta">
            <button className="lp-cta-orange" onClick={() => setPage('consult')}><span>専門スタッフに無料相談する</span><span className="lp-cta-tri">▶</span></button>
          </div>
        </div>
      </section>

      {/* ===== VOICES ===== */}
      <section className="lp-sec">
        <div className="lp-container">
          <LpHead en="VOICE">お客様の声</LpHead>
          <div className="lp-voices">
            {voices.map(c => (
              <article key={c.no} className="lp-voice">
                <div className="lp-voice-tag">{c.industry}</div>
                <h3>{headline(c.comment) || c.industry}</h3>
                <p dangerouslySetInnerHTML={{ __html: c.comment }} />
                <div className="lp-voice-meta">調達金額 <b>{c.amount}</b> / 調達期間 <b>{c.days}</b></div>
              </article>
            ))}
          </div>
        </div>
      </section>

      {/* ===== FAQ ===== */}
      <section className="lp-sec lp-sec-pale">
        <div className="lp-container lp-narrow">
          <LpHead en="FAQ">よくあるご質問</LpHead>
          <LpFaq items={FAQ} />
        </div>
      </section>

      {/* ===== CONTACT FORM ===== */}
      <section className="lp-sec lp-form-sec" id="contact-form">
        <div className="lp-container lp-narrow">
          <LpHead en="CONTACT">無料お見積りフォーム</LpHead>
          <p className="lp-form-lead">ご相談・お見積りは無料です。営業時間内なら最短30分で審査結果をご返答いたします。</p>
          <LpForm setPage={setPage} setConsultEntrySubmissionId={setConsultEntrySubmissionId} />
          <div className="lp-form-tel">
            <LpCtaButtons setPage={setPage} COMPANY={COMPANY} />
          </div>
        </div>
      </section>

      {/* ===== COLUMN (SEO用の内部リンク) ===== */}
      <BlogSection setPage={setPage} setBlogId={setBlogId} limit={6} />

    </div>
  );
}

Object.assign(window, { LPTop });
