* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: #f4f6f9;
  color: #1f2933;
  font-size: 14px;
}
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---- ログイン ---- */
#login-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: #fff; padding: 40px 36px; border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08); width: 360px; max-width: calc(100% - 24px);
}
.login-box h1 { font-size: 20px; margin: 0 0 4px; text-align: center; }
.login-sub { text-align: center; color: #6b7480; margin: 0 0 24px; }
.login-box label { display: block; margin-bottom: 14px; font-weight: 600; }
.login-box input {
  display: block; width: 100%; margin-top: 6px; padding: 10px;
  border: 1px solid #cbd2d9; border-radius: 6px; font-size: 14px;
}

/* ---- ヘッダー ---- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  background: #1e3a5f; color: #fff; padding: 0 20px; height: 52px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 700; font-size: 15px; }
.topbar-nav { display: flex; gap: 4px; }
.nav-btn {
  background: none; border: none; color: #c3d3e6; padding: 8px 14px;
  cursor: pointer; font-size: 14px; border-radius: 6px;
}
.nav-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.role-badge {
  background: rgba(255,255,255,.2); padding: 2px 8px; border-radius: 10px; font-size: 12px;
}

/* ---- 共通 ---- */
.view { padding: 20px; max-width: 1200px; margin: 0 auto; }
.btn {
  background: #fff; border: 1px solid #cbd2d9; border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; color: #1f2933;
}
.btn:hover { background: #f0f3f6; }
.btn.primary { background: #2563ab; border-color: #2563ab; color: #fff; }
.btn.primary:hover { background: #1e5290; }
.btn.danger { background: #fff; border-color: #d64545; color: #d64545; }
.btn.danger:hover { background: #fdf1f1; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; padding: 11px; font-size: 14px; }
.error-msg { color: #d64545; min-height: 18px; font-size: 13px; margin: 4px 0; }
.req { color: #d64545; font-size: 11px; font-weight: normal; }

/* ---- ツールバー ---- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 18px; }
#search-input {
  flex: 1; min-width: 240px; padding: 9px 12px;
  border: 1px solid #cbd2d9; border-radius: 6px; font-size: 14px;
}
.toolbar select { padding: 8px; border: 1px solid #cbd2d9; border-radius: 6px; font-size: 13px; background: #fff; }
.count-label { color: #6b7480; margin-bottom: 8px; font-size: 13px; }

/* ---- テーブル ---- */
.store-table {
  width: 100%; border-collapse: collapse; background: #fff;
  border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.store-table th {
  text-align: left; padding: 10px 12px; background: #e8edf3;
  font-size: 12px; color: #4a5560; white-space: nowrap;
}
.store-table td { padding: 10px 12px; border-top: 1px solid #eef1f4; }
.store-table tbody tr { cursor: pointer; }
.store-table tbody tr:hover { background: #f3f7fc; }
.store-table .empty-row td { text-align: center; color: #9aa3ad; padding: 30px; cursor: default; }

/* ---- ステータスバッジ ---- */
.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status-顧問店 { background: #e3edfb; color: #2563ab; }
.status-在籍契約店 { background: #e1f3e5; color: #1e7a35; }
.status-在なし店 { background: #f2f2f2; color: #828a93; }

/* ---- ページネーション ---- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pagination button {
  border: 1px solid #cbd2d9; background: #fff; border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
.pagination button.current { background: #2563ab; color: #fff; border-color: #2563ab; }
.pagination button:disabled { opacity: .4; cursor: default; }

/* ---- 詳細 ---- */
.detail-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin-top: 14px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-left, .detail-right { display: flex; flex-direction: column; gap: 16px; }
.detail-head { margin-top: 14px; }
.detail-updated { color: #6b7480; font-size: 12px; margin-top: 6px; }
.card {
  background: #fff; border-radius: 8px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 20px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.info-list { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; }
.info-list dt { color: #6b7480; font-size: 13px; }
.info-list dd { margin: 0; white-space: pre-wrap; word-break: break-all; }

/* ---- セクションヘッダー（更新確認） ---- */
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h3 { margin: 0; }
.stale-badge {
  background: #fdecec; color: #c0392b; border: 1px solid #f3c1bd;
  border-radius: 12px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.section-head.is-stale { background: #fff8f7; margin: -8px -8px 12px; padding: 8px; border-radius: 8px; }
.confirm-btn { white-space: nowrap; }

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,32,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; padding: 24px 28px;
  width: 640px; max-width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal.narrow { width: 400px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid.one-col { grid-template-columns: 1fr; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 9px; border: 1px solid #cbd2d9; border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---- トースト ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2933; color: #fff; padding: 11px 22px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 200;
}

/* ---- 募集状況バッジ ---- */
.status-募集中 { background: #e1f3e5; color: #1e7a35; }
.status-停止中 { background: #f2f2f2; color: #828a93; }
.status-要確認 { background: #fcf0dc; color: #b0721c; }

/* ---- 項目別更新メタ・セクション ---- */
.muted { color: #9aa3ad; font-weight: normal; font-size: 12px; }
.sub-text { display: block; color: #9aa3ad; font-size: 11px; }
.field-value { white-space: pre-wrap; word-break: break-word; }
.field-meta { color: #9aa3ad; font-size: 11px; margin-top: 3px; }
.section-updated { float: right; color: #9aa3ad; font-size: 11px; font-weight: normal; }
.info-list dd { border-bottom: 1px solid #f3f5f7; padding-bottom: 6px; }
.info-list dt { padding-top: 2px; }

/* ---- 変更履歴 ---- */
.changes-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.change-item { border-left: 3px solid #d7dee6; padding: 2px 0 2px 10px; }
.change-meta { font-size: 11px; color: #9aa3ad; }
.change-body { font-size: 13px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.change-label { font-weight: 600; color: #2563ab; white-space: nowrap; }
.change-old { color: #9aa3ad; text-decoration: line-through; }
.change-arrow { color: #9aa3ad; }
.change-new { color: #1f2933; }

/* ---- 編集フォーム ---- */
.wide-modal { width: 860px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.modal-head h2 { margin: 0; }
.form-section-title {
  margin: 18px 0 10px; padding: 7px 12px; background: #e8edf3;
  border-radius: 6px; font-size: 14px; color: #1e3a5f;
}
.paste-area {
  background: #f3f7fc; border: 1px dashed #9db8d4; border-radius: 8px;
  padding: 12px; margin-bottom: 12px;
}
.paste-area p { margin: 0 0 8px; }
.paste-area textarea {
  width: 100%; padding: 9px; border: 1px solid #cbd2d9; border-radius: 6px;
  font-size: 13px; font-family: inherit; resize: vertical;
}

/* ---- 紹介料タグ ---- */
.tag-chip {
  display: inline-block; background: #f0e6f7; color: #6b3fa0;
  border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 600;
  margin-right: 4px;
}
.tag-row { display: block; margin-top: 3px; }
.tag-checks { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 4px 0; }
.tag-check {
  display: flex !important; flex-direction: row !important; align-items: center;
  gap: 5px !important; font-weight: normal !important; cursor: pointer;
}
.tag-check input { width: auto; }

/* ---- 店舗面接官 ---- */
.interviewer-row { display: flex; gap: 8px; margin-bottom: 8px; }
.interviewer-row input {
  flex: 1; padding: 9px; border: 1px solid #cbd2d9; border-radius: 6px; font-size: 14px;
}
.interviewer-item { margin-bottom: 6px; }
.interviewer-contact { color: #4a5560; margin-left: 12px; font-size: 13px; }

/* ---- もしかして候補 ---- */
.suggest-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #fff8f0; border: 1px solid #f0d9bd; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px;
}
.suggest-label { color: #7a5520; font-size: 13px; font-weight: 600; }
.suggest-chip {
  background: #fff; border: 1px solid #d8a86a; color: #b0721c;
  border-radius: 14px; padding: 5px 14px; font-size: 13px; cursor: pointer;
}
.suggest-chip:hover { background: #2563ab; border-color: #2563ab; color: #fff; }

/* ---- 提携者用テキスト共有 ---- */
.share-note {
  background: #fff8f0; border: 1px solid #f0d9bd; border-radius: 8px;
  padding: 10px 12px; font-size: 13px; color: #7a5520; margin: 0 0 12px;
}
.share-text {
  width: 100%; padding: 12px; border: 1px solid #cbd2d9; border-radius: 8px;
  font-size: 14px; font-family: inherit; line-height: 1.6; resize: vertical;
  white-space: pre-wrap; word-break: break-word;
}

/* ---- ユーザー一覧 ---- */
.user-actions { display: flex; gap: 6px; justify-content: flex-end; }
.store-table tbody tr.no-hover { cursor: default; }
.store-table tbody tr.no-hover:hover { background: #fff; }
.store-table td:first-child strong { font-weight: 700; }

/* ============================================================
   スマホ対応（幅640px以下）
   ============================================================ */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .view { padding: 12px; }
  .card { padding: 14px; }

  /* ---- ヘッダー：2段組みにする ---- */
  .topbar {
    height: auto; flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px;
  }
  .topbar-title { width: 100%; font-size: 15px; }
  .topbar-nav { order: 2; gap: 2px; }
  .topbar-user { order: 3; margin-left: auto; gap: 6px; }
  #me-name, #me-role { display: none; }
  .nav-btn { padding: 7px 10px; font-size: 13px; }

  /* ---- タップしやすいボタン ---- */
  .btn { padding: 9px 14px; }
  .btn.small { padding: 6px 10px; font-size: 12px; }

  /* ---- ツールバー：検索は全幅、絞り込みは2列 ---- */
  .toolbar { gap: 8px; }
  #search-input { flex: 1 1 100%; min-width: 0; }
  .toolbar select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .toolbar > .btn { flex: 1 1 calc(50% - 4px); }
  .toolbar .spacer { display: none; }

  /* ---- 店舗一覧：表をカード表示に ---- */
  .store-table { background: transparent; box-shadow: none; }
  .store-table thead { display: none; }
  .store-table, .store-table tbody { display: block; }
  .store-table tr {
    display: block; background: #fff; border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 10px; padding: 12px 14px;
  }
  .store-table td {
    display: flex; justify-content: space-between; gap: 12px;
    border-top: none; padding: 4px 0; text-align: right;
  }
  .store-table td::before {
    content: attr(data-label); color: #6b7480; font-size: 12px;
    text-align: left; white-space: nowrap; font-weight: 600;
  }
  .store-table td[data-empty] { display: none; }
  .store-table td:first-child {
    display: block; text-align: left; font-size: 16px;
    margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #eef1f4;
  }
  .store-table td:first-child::before { display: none; }
  .store-table .empty-row td { display: block; text-align: center; border: none; }
  .store-table .empty-row td::before { display: none; }

  /* ---- 詳細：項目を縦積みに ---- */
  .info-list { grid-template-columns: 1fr; gap: 0; }
  .info-list dt { padding-top: 10px; font-weight: 600; color: #4a5560; }
  .info-list dd { padding-bottom: 8px; }
  .section-updated { float: none; display: block; margin-top: 2px; }
  .detail-head .card-head { flex-wrap: wrap; }
  .detail-head .card-head h2 { font-size: 18px; width: 100%; }

  /* ---- モーダル・フォーム：1列＆全幅 ---- */
  .modal-overlay { padding: 8px; align-items: flex-start; }
  .modal { padding: 16px; border-radius: 10px; max-height: 96vh; }
  .wide-modal, .modal.narrow { width: 100%; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .modal-actions { position: sticky; bottom: -16px; background: #fff; padding: 10px 0 2px; margin-top: 4px; }
  .modal-actions .btn { flex: 1; }

  /* ---- 面接官：縦積み ---- */
  .interviewer-row { flex-wrap: wrap; gap: 6px; padding: 10px; background: #f7f9fb; border-radius: 8px; }
  .interviewer-row input { flex: 1 1 100%; }

  /* ---- 変更履歴・共有テキスト ---- */
  .changes-list { max-height: none; }
  .share-text { font-size: 15px; }
}
