/* ==============================
   UTMログ分析レポート スタイルシート
   ============================== */

/* リセット・基本設定 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* カラーパレット（ダークブルー系） */
  --color-header-bg:     #1a2744;
  --color-header-text:   #ffffff;
  --color-accent:        #2563eb;
  --color-accent-light:  #3b82f6;
  --color-accent-hover:  #1d4ed8;
  --color-bg:            #f0f4f8;
  --color-card-bg:       #ffffff;
  --color-border:        #d1d9e0;
  --color-text-primary:  #1e293b;
  --color-text-secondary:#64748b;
  --color-text-muted:    #94a3b8;
  --color-success:       #16a34a;
  --color-success-bg:    #dcfce7;
  --color-error:         #dc2626;
  --color-error-bg:      #fee2e2;
  --color-warning:       #d97706;
  --color-warning-bg:    #fef3c7;
  --color-pass:          #16a34a;
  --color-block:         #dc2626;
  /* テーブル */
  --color-table-header:  #1e3a5f;
  --color-table-stripe:  #f1f5f9;
  --color-table-hover:   #e8f0fe;
  /* シャドウ */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12);
  /* 角丸 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  /* フォント */
  --font-base: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans',
               'Meiryo', 'Yu Gothic', sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ==============================
   ヘッダー
   ============================== */
.app-header {
  background: linear-gradient(135deg, #1a2744 0%, #1e3a5f 60%, #1a4a8a 100%);
  color: var(--color-header-text);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.header-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.header-subtitle {
  font-size: .8rem;
  color: rgba(255,255,255,.65);
  margin-top: 2px;
  letter-spacing: .02em;
}

/* ==============================
   メインコンテンツ
   ============================== */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==============================
   カード共通
   ============================== */
.card {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.card-header {
  background: linear-gradient(90deg, #1e3a5f, #1a4a8a);
  color: #fff;
  padding: 14px 20px;
  font-size: .95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* ==============================
   ドラッグ＆ドロップエリア
   ============================== */
.upload-area {
  border: 2.5px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background-color .2s, transform .15s;
  background: #f8fafc;
  user-select: none;
}

.upload-area:hover {
  border-color: var(--color-accent-light);
  background: #eff6ff;
}

/* ドラッグオーバー時のハイライト */
.upload-area.drag-over {
  border-color: var(--color-accent);
  background: #dbeafe;
  transform: scale(1.01);
  box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  color: var(--color-accent-light);
  display: block;
}

.upload-text-primary {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.upload-text-secondary {
  font-size: .85rem;
  color: var(--color-text-secondary);
  margin-bottom: 18px;
}

.btn-upload {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  padding: 10px 26px;
  border-radius: 100px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  border: none;
  letter-spacing: .02em;
}

.btn-upload:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
}

.btn-upload:active {
  transform: translateY(0);
}

/* 隠しファイル入力 */
#fileInput {
  display: none;
}

/* ==============================
   ステータスエリア
   ============================== */
.status-area {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all .3s;
}

.status-area.hidden {
  display: none;
}

.status-area.loading {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--color-accent);
}

.status-area.success {
  background: var(--color-success-bg);
  border: 1px solid #86efac;
  color: var(--color-success);
}

.status-area.error {
  background: var(--color-error-bg);
  border: 1px solid #fca5a5;
  color: var(--color-error);
}

/* スピナー */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(37,99,235,.25);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==============================
   統計情報エリア
   ============================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.stat-item {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  text-align: center;
  transition: box-shadow .2s;
}

.stat-item:hover {
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: .78rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
}

.stat-value.large-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* アクション別件数 */
.action-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.action-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 100px;
  font-size: .85rem;
  font-weight: 600;
}

.action-badge.pass {
  background: #dcfce7;
  color: var(--color-pass);
  border: 1px solid #86efac;
}

.action-badge.block {
  background: #fee2e2;
  color: var(--color-block);
  border: 1px solid #fca5a5;
}

.action-badge.other {
  background: #f1f5f9;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

/* ==============================
   データプレビューテーブル
   ============================== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  white-space: nowrap;
}

.data-table thead th {
  background: var(--color-table-header);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  letter-spacing: .03em;
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: .8rem;
}

.data-table tbody tr {
  border-bottom: 1px solid #e8edf2;
  transition: background .15s;
}

/* ストライプ表示 */
.data-table tbody tr:nth-child(even) {
  background: var(--color-table-stripe);
}

.data-table tbody tr:hover {
  background: var(--color-table-hover);
}

.data-table tbody td {
  padding: 9px 14px;
  color: var(--color-text-primary);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* アクション列のバッジ */
.badge-pass {
  background: #dcfce7;
  color: var(--color-pass);
  padding: 2px 10px;
  border-radius: 100px;
  font-size: .78rem;
  font-weight: 600;
}

.badge-block {
  background: #fee2e2;
  color: var(--color-block);
  padding: 2px 10px;
  border-radius: 100px;
  font-size: .78rem;
  font-weight: 600;
}

.preview-count {
  font-size: .82rem;
  color: var(--color-text-muted);
  padding: 10px 0 0;
  text-align: right;
}

/* 空状態表示 */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
  opacity: .4;
}

.empty-state-text {
  font-size: .95rem;
}

/* ==============================
   ステップ3：ホワイトリスト管理
   ============================== */

/* ---- 折りたたみセクション ---- */
.collapsible-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: background .2s;
}

.collapsible-header:hover {
  background: linear-gradient(90deg, #163050, #1a5a9a);
}

/* 矢印アイコン（折りたたみ状態：右向き、展開状態：下向き） */
.collapse-arrow {
  font-size: .75rem;
  transition: transform .25s;
  margin-left: auto;
  padding-left: 12px;
}

.collapsible.open .collapse-arrow {
  transform: rotate(90deg);
}

/* ---- ホワイトリスト統計バー ---- */
.wl-stats-bar {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: .88rem;
}

.wl-stats-text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.wl-stats-total {
  font-weight: 600;
  color: var(--color-text-primary);
  margin-left: 4px;
}

/* ---- ソースバッジ ---- */
.wl-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}

/* 初期登録：青系 */
.wl-badge-initial {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}

/* ユーザー追加：緑系 */
.wl-badge-user {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

/* AI判定：紫系 */
.wl-badge-ai {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #d8b4fe;
}

/* ---- ホワイトリストテーブル ---- */
.wl-table-wrap {
  overflow-x: auto;
  margin-bottom: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.wl-table {
  font-size: .82rem;
}

.wl-domain-cell {
  font-size: .78rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wl-reason-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-secondary);
  font-size: .8rem;
}

/* ---- 削除ボタン ---- */
.btn-wl-delete {
  background: #fee2e2;
  color: var(--color-block);
  border: 1px solid #fca5a5;
  padding: 3px 12px;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.btn-wl-delete:hover {
  background: #fca5a5;
}

/* ---- 追加フォーム ---- */
.wl-add-form {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.wl-form-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 12px;
}

/* フォームをグリッドで横並び */
.wl-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 14px;
  margin-bottom: 12px;
}

.wl-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 2列分の幅 */
.wl-field-wide {
  grid-column: span 2;
}

/* 3列分の幅（理由フィールド） */
.wl-field-full {
  grid-column: span 3;
}

.wl-form-field label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.wl-form-field input {
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-family: var(--font-base);
  color: var(--color-text-primary);
  background: #fff;
  transition: border-color .15s;
  outline: none;
}

.wl-form-field input:focus {
  border-color: var(--color-accent-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* 必須マーク */
.required {
  color: var(--color-block);
  margin-left: 2px;
}

.wl-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 追加ボタン */
.btn-wl-add {
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 100px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.btn-wl-add:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
}

.btn-wl-add:active {
  transform: translateY(0);
}

/* ---- フォームメッセージ ---- */
.wl-form-msg {
  font-size: .85rem;
  min-height: 1.2em;
  transition: color .2s;
}

.wl-msg-success { color: var(--color-success); }
.wl-msg-error   { color: var(--color-error);   }

/* ---- エクスポート/インポートボタン ---- */
.wl-io-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-wl-export,
.btn-wl-import {
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  border: 1px solid;
}

.btn-wl-export {
  background: #eff6ff;
  color: var(--color-accent);
  border-color: #bfdbfe;
}

.btn-wl-export:hover {
  background: #dbeafe;
}

.btn-wl-import {
  background: #f0fdf4;
  color: var(--color-success);
  border-color: #86efac;
}

.btn-wl-import:hover {
  background: #dcfce7;
}

/* ---- レスポンシブ（フォームグリッド） ---- */
@media (max-width: 768px) {
  .wl-form-grid {
    grid-template-columns: 1fr;
  }

  .wl-field-wide,
  .wl-field-full {
    grid-column: span 1;
  }
}

/* ==============================
   ステップ2：レポートセクション
   ============================== */

/* レポートセクション群の非表示切り替え */
#report-sections.hidden {
  display: none;
}

/* ---- サマリーカード ---- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.summary-card {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
}

.summary-card.pass-card {
  border-color: #86efac;
  background: #f0fdf4;
}

.summary-card.block-card {
  border-color: #fca5a5;
  background: #fff1f1;
}

.summary-card.block-card-warn {
  border-color: #dc2626;
  background: #fee2e2;
}

.summary-label {
  font-size: .75rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
}

.pass-value  { color: var(--color-pass);  }
.block-value { color: var(--color-block); }

.summary-period {
  font-size: .88rem;
  padding: 10px 0 8px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.summary-extra {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.summary-extra-row {
  font-size: .85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* ---- 警告テキスト ---- */
.warn-text {
  color: var(--color-block);
  font-weight: 700;
}

.pass-text  { color: var(--color-pass);  font-weight: 600; }
.block-text { color: var(--color-block); font-weight: 600; }
.text-muted { color: var(--color-text-muted); }

/* ---- カードヘッダー（警告） ---- */
.card-header-warn {
  background: linear-gradient(90deg, #7f1d1d, #dc2626);
}

/* ---- ハイライト行（Block件数>0） ---- */
.data-table tbody tr.row-highlight {
  background: #fff1f1 !important;
}

.data-table tbody tr.row-highlight:hover {
  background: #ffe4e4 !important;
}

/* ---- テーブル内バッジ（カテゴリ） ---- */
.category-badge {
  display: inline-block;
  background: #eff6ff;
  color: var(--color-accent);
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: .78rem;
  font-weight: 500;
  margin: 1px 2px;
  white-space: nowrap;
}

.category-badge small {
  color: var(--color-text-secondary);
  margin-left: 3px;
}

/* ---- URLバッジ ---- */
.url-badge {
  display: inline-block;
  background: #f1f5f9;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  padding: 2px 8px;
  border-radius: 100px;
  font-size: .78rem;
  margin: 1px 2px;
  white-space: nowrap;
}

.url-small {
  display: block;
  font-size: .78rem;
  color: var(--color-text-secondary);
  word-break: break-all;
  line-height: 1.5;
}

.url-small small {
  color: var(--color-text-muted);
  margin-left: 3px;
}

/* ---- テーブルセルのスタイル ---- */
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.data-table td.mono {
  font-family: var(--font-mono);
  font-size: .8rem;
}

.data-table td.nowrap {
  white-space: nowrap;
}

.data-table td.url-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .8rem;
}

.data-table td.rank-cell {
  color: var(--color-text-muted);
  font-size: .82rem;
  width: 36px;
}

/* ---- ブロック通信テーブルのスクロール（最大高さ400px） ---- */
.table-scroll-400 {
  max-height: 400px;
  overflow-y: auto;
  border-radius: var(--radius-md);
}

.table-scroll-400 .table-container {
  border-radius: 0;
}

/* 500件超過メッセージ */
.over-limit-msg {
  background: var(--color-warning-bg);
  border: 1px solid #fcd34d;
  color: var(--color-warning);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: .88rem;
  margin-bottom: 12px;
}

/* ---- グラフセクション ---- */
.chart-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.chart-card {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-card canvas {
  max-height: 300px;
}

/* タイムラインとアプリグラフはcanvasの高さを固定 */
.chart-canvas-tall {
  height: 300px !important;
  max-height: 300px !important;
  width: 100% !important;
}

.chart-full {
  width: 100%;
  display: block;
}

.mt-16 {
  margin-top: 16px;
}

/* ==============================
   印刷用スタイル
   ============================== */
@media print {
  .app-header   { position: static; print-color-adjust: exact; }
  .upload-area,
  #fileInput,
  #uploadBtn    { display: none; }
  .card         { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  .main-content { padding: 0; }
  .chart-grid-2col { grid-template-columns: 1fr 1fr; }
  .table-scroll-400 { max-height: none; overflow: visible; }
  body          { font-size: 12px; }
}

/* ==============================
   レスポンシブ対応
   ============================== */
@media (max-width: 768px) {
  .app-header {
    padding: 14px 16px;
  }

  .header-title {
    font-size: 1.1rem;
  }

  .main-content {
    padding: 16px 12px 32px;
    gap: 16px;
  }

  .card-body {
    padding: 14px;
  }

  .upload-area {
    padding: 28px 16px;
  }

  .upload-icon {
    font-size: 2.2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-value {
    font-size: 1.3rem;
  }

  /* グラフはモバイルで1列 */
  .chart-grid-2col {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .header-subtitle {
    display: none;
  }
}

/* ==============================
   ステップ4：AI誤検知判定 UI
   ============================== */

/* ---- サーバー状態表示 ---- */
.health-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 20px;
}
.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-checking { background: #f1f5f9; color: var(--color-text-secondary); }
.health-checking .health-dot { background: var(--color-text-muted); }
.health-ok      { background: var(--color-success-bg); color: var(--color-success); }
.health-ok      .health-dot { background: var(--color-success); }
.health-warn    { background: var(--color-warning-bg); color: var(--color-warning); }
.health-warn    .health-dot { background: var(--color-warning); }
.health-error   { background: var(--color-error-bg); color: var(--color-error); }
.health-error   .health-dot { background: var(--color-error); }

/* ---- カテゴリ選択エリア ---- */
.judge-category-section {
  margin-bottom: 20px;
}
.judge-section-label {
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 10px;
  font-size: .95rem;
}
.judge-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 16px;
}
.judge-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--color-text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fff;
  transition: background .15s, border-color .15s;
  user-select: none;
}
.judge-checkbox-label:hover {
  background: var(--color-table-stripe);
  border-color: var(--color-accent-light);
}
.judge-checkbox-label input[type="checkbox"] {
  accent-color: var(--color-accent);
  width: 15px;
  height: 15px;
}
.judge-cat-count {
  color: var(--color-text-muted);
  font-size: .82rem;
}
.judge-no-category {
  color: var(--color-text-muted);
  font-size: .9rem;
}

/* ---- アクションボタン ---- */
.judge-action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-judge {
  padding: 9px 20px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-judge:hover:not(:disabled) { background: var(--color-accent-hover); }
.btn-judge:disabled {
  background: #93c5fd;
  cursor: not-allowed;
  opacity: .7;
}
.btn-judge-clear {
  padding: 9px 16px;
  background: #fff;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.btn-judge-clear:hover {
  background: var(--color-table-stripe);
  border-color: var(--color-accent-light);
  color: var(--color-text-primary);
}

/* ---- 進捗バー ---- */
.judge-progress-label {
  font-size: .88rem;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}
.judge-progress-bar-wrap {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.judge-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-light));
  border-radius: 9999px;
  transition: width .3s ease;
}

/* ---- 判定サマリー ---- */
.judge-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.judge-summary-item {
  background: var(--color-table-stripe);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  border: 1px solid var(--color-border);
}
.judge-summary-label {
  font-size: .78rem;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}
.judge-summary-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text-primary);
}
.judge-summary-miss  .judge-summary-value { color: var(--color-error); }
.judge-summary-correct .judge-summary-value { color: var(--color-success); }
.judge-summary-error  .judge-summary-value { color: var(--color-warning); }
.judge-summary-rate   .judge-summary-value { color: var(--color-accent); }

/* ---- 判定結果テーブル ---- */
.judge-table-wrap {
  max-height: 480px;
  overflow: auto;
}
.judge-result-table th,
.judge-result-table td {
  white-space: nowrap;
}
.judge-url-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.judge-reason-cell {
  max-width: 260px;
  white-space: normal;
  font-size: .82rem;
  line-height: 1.4;
}
.judge-row-miss {
  background-color: #fff1f2 !important;
}
.judge-row-miss:hover {
  background-color: #ffe4e6 !important;
}
.judge-no-results {
  color: var(--color-text-muted);
  padding: 16px 0;
  text-align: center;
}

/* ---- 判定元バッジ ---- */
.judge-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: .78rem;
  font-weight: 600;
}
.judge-badge-wl    { background: #dbeafe; color: #1d4ed8; }
.judge-badge-ai    { background: #ede9fe; color: #6d28d9; }
.judge-badge-error { background: var(--color-error-bg); color: var(--color-error); }

/* ---- 判定結果バッジ ---- */
.judge-result-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: .78rem;
  font-weight: 600;
}
.judge-result-miss    { background: #fee2e2; color: #b91c1c; }
.judge-result-known   { background: #fef3c7; color: #92400e; }
.judge-result-ok      { background: #dcfce7; color: #166534; }
.judge-result-unknown { background: #f1f5f9; color: #64748b; }

/* ---- リスクバッジ ---- */
.risk-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: .78rem;
  font-weight: 600;
}
.risk-safe       { background: #dcfce7; color: #166534; }
.risk-suspicious { background: #fef9c3; color: #854d0e; }
.risk-dangerous  { background: #fee2e2; color: #b91c1c; }

/* ---- ホワイトリスト追加ボタン ---- */
.btn-add-wl {
  padding: 4px 10px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
}
.btn-add-wl:hover { background: var(--color-accent-hover); }

/* ---- テキスト右寄せ ---- */
.text-right { text-align: right; }

/* ---- URL列 ---- */
.judge-url-cell {
  min-width: 200px;
  word-break: break-all;
  font-size: .82rem;
  max-width: 320px;
}

/* ---- 理由列 ---- */
.judge-reason-cell {
  min-width: 300px;
  white-space: normal;
  line-height: 1.5;
  font-size: .82rem;
}

/* ---- エラー行 ---- */
tr.judge-row-error td {
  background-color: #fff5f5 !important;
}
tr.judge-row-error:hover td {
  background-color: #ffe8e8 !important;
}

/* ==============================
   ステップ5: 統合分析レポート
   ============================== */

/* ---- 統合レポートセクション ---- */
#integrated-report {
  margin-top: 24px;
}

.report-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--color-border);
}
.report-section:last-child {
  border-bottom: none;
}

/* 印刷専用見出し（画面表示時は非表示、印刷時のみ表示） */
.print-only-heading {
  display: none;
}

/* 印刷専用テーブル（画面表示時は非表示、印刷時のみ表示） */
.judge-summary-print-table,
.judge-print-table {
  display: none;
}

/* ---- セクションタイトル ---- */
.ir-section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-header-bg);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-accent);
}

/* ---- 空状態 ---- */
.ir-empty {
  color: var(--color-text-muted);
  padding: 16px 0;
  text-align: center;
}

/* ---- 注記 ---- */
.ir-note {
  font-size: .82rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}
.ir-note-bottom {
  margin-top: 12px;
  margin-bottom: 0;
}

/* ---- 未判定テキスト ---- */
.ir-undecided {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ---- エグゼクティブサマリー ---- */
.ir-exec-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.ir-exec-card {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.ir-exec-label {
  font-size: .78rem;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}
.ir-exec-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-primary);
}
.ir-exec-period {
  font-size: .9rem;
}
.ir-exec-block {
  background: #fff5f5;
  border-color: #fca5a5;
}
.ir-exec-comment {
  background: #f0f7ff;
  border-left: 4px solid var(--color-accent);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .9rem;
  line-height: 1.6;
}

/* ---- カテゴリ別分析テーブル ---- */
.ir-cat-table td, .ir-cat-table th {
  vertical-align: middle;
}
.ir-row-warning td {
  background-color: #fff8e1 !important;
}
.ir-toggle-link {
  cursor: pointer;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  user-select: none;
}
.ir-toggle-link:hover {
  color: var(--color-accent-hover);
}
.ir-arrow {
  font-size: .7rem;
  display: inline-block;
  transition: transform .15s;
}
.ir-detail-row td {
  background: #f8fafc;
  padding: 8px 12px;
}
.ir-fp-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ir-fp-item {
  font-size: .82rem;
  color: var(--color-text-secondary);
  padding: 2px 0;
}

/* ---- 端末別ランキング ---- */
.ir-risk-reason {
  font-size: .82rem;
  white-space: normal;
  line-height: 1.5;
  min-width: 200px;
}

/* ---- 端末別詳細アコーディオン ---- */
.ir-mac-detail-block {
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ir-mac-accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #f1f5f9;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--color-border);
  transition: background .15s;
}
.ir-mac-accordion-header:hover {
  background: #e2e8f0;
}
.ir-mac-accordion-header:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.ir-accordion-arrow {
  font-size: .75rem;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  width: 12px;
  text-align: center;
}

.ir-mac-block-count {
  font-size: .85rem;
  color: var(--color-text-secondary);
  margin-left: auto;
}

.ir-mac-accordion-body {
  padding: 12px;
  background: #fff;
}

.ir-over-limit {
  margin-top: 8px;
  font-size: .82rem;
  color: var(--color-text-secondary);
  text-align: right;
  padding-right: 4px;
}

/* ---- 傾向分析グリッド ---- */
.ir-trend-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.ir-trend-card {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.ir-trend-label {
  font-size: .78rem;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}
.ir-trend-value {
  font-size: .95rem;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.5;
}

/* ---- 対策提案タイトル ---- */
.ir-rec-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 12px;
  margin-top: 4px;
}

/* ---- 対策提案カード ---- */
.ir-rec-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recommendation-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid transparent;
  background: #f8fafc;
}

/* ルール1: 判定ルール見直し（誤検知率≥80%）→ 黄色 */
.recommendation-warning {
  border-left-color: #d97706;
  background: #fffbeb;
}

/* ルール2: カテゴリ分類再検討（同一ドメイン複数カテゴリ）→ 青色 */
.recommendation-info {
  border-left-color: var(--color-accent);
  background: #eff6ff;
}

/* ルール3: UTMホワイトリスト追加（WL済みがブロック）→ 緑色 */
.recommendation-success {
  border-left-color: var(--color-success);
  background: #f0fdf4;
}

/* ルール4: 該当なし → 灰色 */
.recommendation-neutral {
  border-left-color: #94a3b8;
  background: #f8fafc;
}

.recommendation-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.recommendation-text {
  font-size: .9rem;
  line-height: 1.6;
  color: var(--color-text-primary);
}

/* ---- 印刷ボタン ---- */
.btn-print {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--color-header-bg);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}
.btn-print:hover:not(:disabled) {
  background: #1e3a5f;
}
.btn-print:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- プレースホルダーテキスト ---- */
.placeholder-text {
  color: var(--color-text-muted);
  text-align: center;
  padding: 24px 0;
  font-size: .9rem;
}

/* ---- risk-unknown バッジ（未定義分）---- */
.risk-unknown {
  background: #e9ecef;
  color: #64748b;
}

/* ---- レスポンシブ対応 ---- */
@media (max-width: 768px) {
  .judge-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .judge-action-buttons {
    flex-direction: column;
  }
  .btn-judge,
  .btn-judge-clear {
    width: 100%;
    text-align: center;
  }
}
