:root {
  --primary-color: #2c3e50;
  --border-color: #333;
  --bg-light: #f8f9fa;
  --ok-color: #27ae60;
  --error-color: #e74c3c;
}

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "メイリオ", sans-serif;
  margin: 0;
  padding: 20px 0;
  background-color: #f4f6f9;
  color: #333;
}

/* 全体3カラムレイアウト */
.app-layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 15px;
  max-width: 1440px;
  margin: 0 auto;
  padding-bottom: 40px;
}

/* 左右サイドバー広告枠 */
.sidebar-ad {
  width: 160px;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.ad-label {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-bottom: 4px;
}

.ad-placeholder {
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.4;
  margin: 0;
}

/* メインコンテナ */
.container {
  width: 900px;
  margin: 0;
  background: #fff;
  padding: 20px 30px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
  border-radius: 8px;
}

h1 {
  text-align: center;
  color: #1e293b;
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.6rem;
}

/* コントロールパネル */
.control-panel {
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 15px 20px;
  margin-bottom: 25px;
}

.header-form-card h3, .upload-card h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.05rem;
  color: #334155;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: bold;
  color: #475569;
  margin-bottom: 4px;
}

.form-group input, .form-group select {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.85rem;
}

.form-group select {
  background-color: #fff;
}

/* ドロップエリア */
.drop-zone {
  border: 2px dashed #94a3b8;
  border-radius: 6px;
  padding: 20px;
  text-align: center;
  background-color: #fff;
  transition: all 0.2s;
  margin-bottom: 15px;
}

.drop-zone.dragover {
  background-color: #eff6ff;
  border-color: #2563eb;
}

.drop-zone p {
  margin: 0 0 10px 0;
  color: #64748b;
  font-size: 0.9rem;
}

/* ボタン群 */
.btn-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 9px 16px;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.85rem;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-primary { background-color: #2563eb; color: #fff; }
.btn-secondary { background-color: #64748b; color: #fff; }
.btn-info { background-color: #0f766e; color: #fff; }
.btn-success { background-color: #16a34a; color: #fff; }

/* ステータスメッセージ */
.status-msg {
  text-align: center;
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: bold;
}
.status-msg.success { color: #16a34a; }
.status-msg.error { color: #dc2626; }

/* 帳票ページスタイル */
.report-page {
  background: #fff;
  padding: 15px 0;
}

.pl-page {
  margin-bottom: 30px;
}

.report-header {
  border-bottom: 2px solid #000;
  padding-bottom: 4px;
  margin-bottom: 10px;
}

.report-title-area {
  display: flex;
  align-items: baseline;
  justify-content: center;
  position: relative;
  margin-bottom: 8px;
}

.report-year {
  position: absolute;
  left: 0;
  font-size: 1rem;
  font-weight: bold;
}

.report-title-area h2 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 2px;
}

.report-meta-table {
  width: 100%;
  border-collapse: collapse;
}

.report-meta-table th, .report-meta-table td {
  border: 1px solid #000;
  padding: 3px 6px;
  font-size: 8.5pt;
}

.report-meta-table th {
  background-color: #f1f5f9;
  width: 12%;
  text-align: center;
}

.report-meta-table td {
  width: 21%;
}

/* テーブルスタイル */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  font-size: 8.5pt;
}

th, td {
  border: 1px solid #000;
  padding: 4px 6px;
}

th {
  background-color: #f1f5f9;
  text-align: center;
}

.amount-col {
  text-align: right;
  font-family: "Courier New", Courier, monospace;
}

.section-header-row {
  background-color: #f8fafc;
  font-weight: bold;
}

.summary-row {
  font-weight: bold;
  background-color: #f1f5f9;
}

.summary-row.highlight {
  background-color: #e2e8f0;
}

.summary-row.highlight-final {
  background-color: #cbd5e1;
  font-size: 9pt;
}

/* B/S レイアウト */
.bs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.bs-col-title {
  text-align: center;
  font-weight: bold;
  background-color: #334155;
  color: #fff;
  padding: 4px;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

/* 翌期繰越元入金計算枠 */
.rollover-box {
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid #000;
  background-color: #f8fafc;
  border-radius: 4px;
}

.rollover-box h4 {
  margin: 0 0 4px 0;
  font-size: 0.85rem;
  color: #1e293b;
}

.rollover-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  font-size: 8pt;
  margin-bottom: 4px;
}

.rollover-result {
  font-size: 8.5pt;
  font-weight: bold;
  border-top: 1px solid #cbd5e1;
  padding-top: 4px;
  color: #0f172a;
}

/* 画面下部 広告枠 */
.bottom-ad-card {
  margin-top: 25px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}

.bottom-ad-card .ad-placeholder {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #64748b;
  font-size: 0.85rem;
  margin: 0;
}

/* SEO用解説・信頼性表示セクション (画面表示用) */
.seo-info-section {
  margin-top: 40px;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.seo-info-section h2 {
  font-size: 1.2rem;
  color: #1e293b;
  margin-top: 0;
  margin-bottom: 12px;
  border-bottom: 2px solid #cbd5e1;
  padding-bottom: 6px;
}

.seo-info-section h3 {
  font-size: 1.05rem;
  color: #334155;
  margin-top: 18px;
  margin-bottom: 8px;
}

.seo-info-section p, .seo-info-section li {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #475569;
}

/* モーダルダイアログ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-content {
  background: #ffffff;
  padding: 24px 28px;
  border-radius: 10px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  text-align: center;
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 6px;
  color: #1e293b;
  font-size: 1.2rem;
}

.modal-subtext {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 12px;
  line-height: 1.4;
}

/* モーダル内 広告枠 */
.modal-ad-box {
  margin: 15px 0;
  padding: 8px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  text-align: center;
}

.modal-ad-box .ad-placeholder {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #64748b;
  font-size: 0.85rem;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}

/* ===================================================
   印刷・PDF出力用スタイル (@media print)
   =================================================== */
@media print {
  body {
    background-color: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-layout {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  /* 不要要素（広告・ボタン・コントロールパネル・モーダル・SEO解説等）の非表示 */
  .control-panel,
  .sidebar-ad,
  .bottom-ad-card,
  .seo-info-section,  /* ← SEO用解説セクションをPDF・印刷から非表示 */
  .modal-overlay,
  .ad-label,
  .ad-placeholder,
  .btn,
  .status-msg,
  aside {
    display: none !important;
  }

  .container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  h1 {
    display: none !important;
  }

  .report-page {
    padding: 0 !important;
    margin: 0 !important;
  }

  /* A4 ページ区切り設定 */
  .pl-page {
    page-break-after: always !important;
    break-after: page !important;
    margin-bottom: 0 !important;
  }

  .bs-page {
    page-break-before: page !important;
    break-before: page !important;
    margin-top: 0 !important;
  }

  .report-header {
    margin-bottom: 6px !important;
    padding-bottom: 2px !important;
    border-bottom: 2px solid #000 !important;
  }

  .report-title-area {
    font-size: 1.1rem !important;
    margin-bottom: 4px !important;
  }

  .report-meta-table {
    margin-bottom: 6px !important;
  }

  .report-meta-table th,
  .report-meta-table td {
    padding: 2px 4px !important;
    font-size: 8pt !important;
  }

  table {
    margin-bottom: 6px !important;
    font-size: 8pt !important;
  }

  th, td {
    padding: 2px 4px !important;
    height: auto !important;
  }

  .bs-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .bs-col-title {
    font-size: 0.85rem !important;
    padding: 3px !important;
    background-color: #334155 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .rollover-box {
    margin-top: 4px !important;
    padding: 4px 8px !important;
    border: 1px solid #000 !important;
    background-color: #f8fafc !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .rollover-box h4 {
    margin-bottom: 4px !important;
    font-size: 0.85rem !important;
  }

  .rollover-grid {
    gap: 6px !important;
    font-size: 7.5pt !important;
  }

  .rollover-result {
    font-size: 8pt !important;
    padding: 3px 6px !important;
  }
}