/* ============================================================
   基本設定
   ============================================================ */
:root {
  --color-primary:  #1a4d8f;
  --color-accent:   #e07b00;
  --color-text:     #222;
  --color-muted:    #666;
  --color-border:   #ddd;
  --color-bg:       #f7f8fa;
  --color-white:    #fff;
  --color-danger:   #c0392b;
  --color-active:   #27ae60;
  --radius:         6px;
  --shadow:         0 1px 4px rgba(0,0,0,.08);
  --font-sans:      "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  margin: 0;
  line-height: 1.7;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   レイアウト
   ============================================================ */
.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 16px;
}

.layout-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  margin-top: 20px;
  margin-bottom: 32px;
  align-items: start;
}
.main-content {
  min-width: 0;
}

@media (max-width: 900px) {
  .layout-main { grid-template-columns: 1fr; }
  .sidebar { order: -1; }  /* モバイルではサイドバーを上に */
}

/* ============================================================
   ヘッダー
   ============================================================ */
.site-header {
  background: var(--color-primary);
  color: var(--color-white);
  padding: 12px 0;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-logo {
  color: var(--color-white);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}
.site-nav a {
  color: rgba(255,255,255,.85);
  margin-left: 20px;
  font-size: .9rem;
}
.site-nav a:hover { color: var(--color-white); text-decoration: none; }

/* ============================================================
   AdSense エリア
   ============================================================ */
.ad-wrap { background: var(--color-white); padding: 8px 0; }
.ad-header { border-bottom: 1px solid var(--color-border); }
.ad-footer { border-top: 1px solid var(--color-border); margin-top: 16px; }
.ad-placeholder {
  width: 300px; height: 250px;
  background: #eef; border: 1px dashed #aac;
  display: flex; align-items: center; justify-content: center;
  color: #889; font-size: .8rem; text-align: center;
}
.ad-detail-inline { margin: 24px 0; }
.ad-item { list-style: none; padding: 8px 0; }
.ad-placeholder--inline {
  width: 100%;
  height: 90px;
  background: #eef;
  border: 1px dashed #aac;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #889;
  font-size: .8rem;
  margin-bottom: 10px;
  border-radius: 6px;
}

/* ============================================================
   検索フォーム
   ============================================================ */
.search-form-section {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.search-form-title {
  font-size: 1.1rem;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-primary);
  color: var(--color-primary);
}
.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.form-group { display: flex; flex-direction: column; flex: 1; min-width: 180px; }
.form-group--wide { flex: 2; }

.form-group label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 4px;
}
.form-group input,
.form-group select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: .95rem;
  font-family: inherit;
  width: 100%;
  background: var(--color-white);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(26,77,143,.12);
}
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 4px; }

/* ============================================================
   ボタン
   ============================================================ */
.btn {
  display: inline-block;
  padding: 9px 24px;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary  { background: var(--color-primary); color: var(--color-white); }
.btn-secondary{ background: #e8eef6; color: var(--color-primary); }
.btn-outline  { border: 1px solid var(--color-primary); color: var(--color-primary); background: transparent; }
.btn-sm       { padding: 6px 16px; font-size: .87rem; }

/* ============================================================
   検索結果
   ============================================================ */
.result-header { margin-bottom: 12px; }
.result-summary { font-size: .9rem; color: var(--color-muted); }
.result-count { font-size: 1.1rem; font-weight: 700; color: var(--color-text); }

.corp-list { list-style: none; margin: 0; padding: 0; }
.corp-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}
.corp-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.12); }

.corp-card__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.corp-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-primary);
}
.corp-name:hover { text-decoration: underline; }

.corp-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: .83rem;
  color: var(--color-muted);
}
.meta-item { display: flex; align-items: center; gap: 3px; }
.icon { width: 13px; height: 13px; fill: currentColor; flex-shrink: 0; }

.corp-number { font-family: monospace; letter-spacing: .05em; }

/* ============================================================
   バッジ
   ============================================================ */
.kind-badge {
  display: inline-block;
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 100px;
  background: #e8eef6;
  color: var(--color-primary);
  font-weight: 600;
  white-space: nowrap;
}
.status-badge {
  display: inline-block;
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
  white-space: nowrap;
}
.status-active { background: #e6f4ea; color: var(--color-active); }
.status-closed { background: #fdecea; color: var(--color-danger); }

/* ============================================================
   ページネーション
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 24px 0;
  flex-wrap: wrap;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px; height: 36px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-primary);
  font-size: .9rem;
  background: var(--color-white);
  text-decoration: none;
  transition: background .12s;
}
.page-btn:hover { background: #e8eef6; text-decoration: none; }
.page-btn--current {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
  font-weight: 700;
}
.page-ellipsis { color: var(--color-muted); line-height: 36px; }

/* ============================================================
   サイドバー
   ============================================================ */
.sidebar { position: sticky; top: 16px; }
.sidebar-box {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.sidebar-box h3 {
  font-size: .95rem;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.kind-list { list-style: none; margin: 0; padding: 0; }
.kind-list li { margin-bottom: 5px; }
.kind-list a { font-size: .88rem; }

/* ============================================================
   法人詳細ページ
   ============================================================ */
.breadcrumb ol {
  display: flex;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  font-size: .85rem;
  color: var(--color-muted);
  flex-wrap: wrap;
}
.breadcrumb li + li::before { content: " › "; margin: 0 6px; }
.breadcrumb a { color: var(--color-primary); }

.corp-detail {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
}
.corp-detail__header { margin-bottom: 20px; }
.corp-detail__name {
  font-size: 1.5rem;
  margin: 0 0 8px;
  line-height: 1.4;
}
.corp-detail__badges { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.detail-table th,
.detail-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: .95rem;
  text-align: left;
  vertical-align: top;
}
.detail-table th {
  width: 160px;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
  background: #f9fafb;
}
.detail-table tr:last-child th,
.detail-table tr:last-child td { border-bottom: none; }

.corp-number-large { font-family: monospace; font-size: 1.05rem; letter-spacing: .08em; }
.text-danger { color: var(--color-danger); font-weight: 600; }

.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ============================================================
   エラーページ
   ============================================================ */
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 4rem; color: var(--color-muted); margin-bottom: 8px; }

/* ============================================================
   検索結果なし
   ============================================================ */
.no-result {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--color-muted);
}

/* ============================================================
   フッター
   ============================================================ */
.site-footer {
  background: #2c3e50;
  color: rgba(255,255,255,.7);
  padding: 20px 0;
  font-size: .83rem;
  text-align: center;
}
.site-footer a { color: rgba(255,255,255,.85); }
.site-footer p { margin: 4px 0; }

/* ============================================================
   レスポンシブ調整
   ============================================================ */
@media (max-width: 600px) {
  .corp-detail { padding: 16px; }
  .detail-table th { width: 100px; }
  .corp-detail__name { font-size: 1.2rem; }
  .form-group { min-width: 100%; }
}

/* ============================================================
   月別統計テーブル
   ============================================================ */
.monthly-stats {
  width: 100%;
  min-width: 0;
  margin-bottom: 20px;
}
.monthly-stats__title {
  font-size: 1.1rem;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-primary);
  color: var(--color-primary);
}
.monthly-stats__scroll-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
  width: 100%;
  max-width: 100%;
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
}
.monthly-stats__table {
  border-collapse: separate;
  border-spacing: 0;
  white-space: nowrap;
  font-size: 0.75rem;
  width: auto;
  min-width: 0;
}
.monthly-stats__table th,
.monthly-stats__table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  text-align: center;
}
/* thead: 縦スクロールで固定 */
.monthly-stats__table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background-color: #f0f4f8;
}
/* 左上角セル: 縦横両方固定 */
.monthly-stats__table thead .monthly-stats__pref-col {
  left: 0;
  z-index: 4;
}
/* 都道府県列（tbody）: 横スクロールで固定 */
.monthly-stats__pref-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background-color: #f0f4f8;
  min-width: 80px;
  text-align: left !important;
  border-right: 2px solid #aac !important;
  font-weight: 600;
}
/* 合計行: 縦スクロールでheadの直下に固定 */
.monthly-stats__total-row td {
  position: sticky;
  top: 34px;
  z-index: 2;
  background-color: #e8eef6;
  font-weight: 700;
}
/* 合計行の都道府県セル: 縦横両方固定 */
.monthly-stats__total-row .monthly-stats__pref-col {
  left: 0;
  z-index: 3;
  background-color: #d0daea;
}
