/* ============================================================
   きずなCRM — shared styles
   ============================================================ */

/* --- Design tokens --- */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4d;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ============================================================
   Shell layout（ヘッダー + メイン + フッター）
   ============================================================ */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: 0.02em;
}

.brand a {
  color: inherit;
  text-decoration: none;
}

.app-subnav {
  display: flex;
  gap: 0;
  padding: 0 1rem;
  background: var(--surface-elevated, #1e293b);
  border-bottom: 1px solid var(--border);
}

.app-subnav__link {
  display: inline-block;
  padding: 0.65rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.app-subnav__link:hover {
  color: var(--text, #e2e8f0);
  background: rgba(148, 163, 184, 0.08);
}

.app-subnav__link.is-active {
  color: var(--accent, #60a5fa);
  border-bottom-color: var(--accent, #60a5fa);
}

.brand a:hover {
  color: var(--accent);
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
}

.main {
  flex: 1;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 0.6rem 1rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ============================================================
   Login
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.25), transparent),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.login-card .sub {
  margin: 0 0 1.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.field {
  margin-bottom: 0.9rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* ============================================================
   共通ボタン
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.52rem 0.95rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ============================================================
   エラーメッセージ / バリデーション
   ============================================================ */
.error-msg {
  margin-top: 1rem;
  padding: 0.65rem;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  font-size: 0.875rem;
}

.error-msg.visible {
  display: block;
}

ul.errorlist {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
  color: #fca5a5;
  font-size: 0.875rem;
}

.hint {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

/* ============================================================
   ページ見出し / ツールバー
   ============================================================ */
.page-title {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.page-desc {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.page-heading {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
}

.page-heading-toolbar {
  flex-wrap: nowrap;
  gap: 0.75rem;
}

.page-heading-lead {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.page-heading-toolbar .page-title {
  margin: 0;
  flex-shrink: 0;
}

.page-heading-toolbar .page-heading-action-btn {
  margin-left: auto;
  flex-shrink: 0;
}

/* 議員詳細: 右上にステージ + アクションボタン */
.page-heading-member-detail {
  align-items: flex-start;
}

.page-heading-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
  min-width: min(100%, 520px);
}

.page-heading-aside .sales-stage-segments {
  width: 100%;
  margin-bottom: 0;
}

.page-heading-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-heading-aside .page-heading-action-btn,
.page-heading-actions .page-heading-action-btn {
  margin-left: 0;
  width: auto;
}

@media (max-width: 640px) {
  .page-heading-toolbar {
    flex-wrap: wrap;
  }

  .page-heading-toolbar .page-heading-action-btn {
    margin-left: 0;
    width: 100%;
  }

  .page-heading-member-detail .page-heading-aside {
    width: 100%;
    min-width: 0;
    align-items: stretch;
  }

  .page-heading-actions {
    width: 100%;
    flex-direction: column;
  }

  .page-heading-actions .page-heading-action-btn {
    width: 100%;
  }
}

.page-heading .page-title,
.page-heading .page-desc {
  margin: 0;
}

.page-meta-chips-stack {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.page-meta-chips {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.35;
}

/* ============================================================
   検索ツールバー + フィルターバー（議員一覧）
   ============================================================ */
.search-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.list-filter-item--search {
  flex: 1 1 200px;
  min-width: min(100%, 200px);
  max-width: 340px;
}

.search-toolbar .search-meta {
  flex: 0 0 auto;
  font-size: 0.875rem;
  color: var(--muted);
  white-space: nowrap;
  padding-bottom: 0.35rem;
}

/* フィルター条件群 */
.list-filter-bar {
  display: contents;
}

.list-filter-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  padding: 0.42rem 0.55rem 0.38rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.78rem;
  min-width: 5.75rem;
  min-height: 3.35rem;
  box-sizing: border-box;
}

.list-filter-item--wide {
  min-width: 8.25rem;
}

/* 議員データ収集の都道府県・市区町村は横並び（display:contents を上書き） */
.collect-pref-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.collect-pref-form .list-filter-item--wide {
  flex: 1 1 12rem;
}

.list-filter-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.list-filter-value {
  color: var(--text);
  font-weight: 600;
}

.list-filter-item select {
  min-width: 0;
  width: 100%;
  padding: 0.1rem 1.35rem 0.1rem 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  font-family: inherit;
}

.list-filter-item input[type="search"],
.list-filter-item input[type="text"] {
  min-width: 0;
  width: 100%;
  padding: 0.1rem 0;
  border: none;
  background: transparent;
  background-color: transparent;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  box-shadow: none;
}

.list-filter-item input[type="search"]::-webkit-search-decoration,
.list-filter-item input[type="search"]::-webkit-search-cancel-button,
.list-filter-item input[type="search"]::-webkit-search-results-button,
.list-filter-item input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.list-filter-item input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.list-filter-item input[type="search"]:focus,
.list-filter-item input[type="text"]:focus {
  outline: none;
}

.list-filter-item input[type="search"]:focus-visible,
.list-filter-item input[type="text"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.list-filter-item select option {
  color: #000;
}

.list-filter-item #pref-filter,
.list-filter-item #order-filter {
  min-width: 0;
}

.list-filter-item select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.list-filter-item select:focus {
  outline: none;
}

.list-filter-actions {
  display: inline-flex;
  align-items: stretch;
  gap: 0.45rem;
  flex: 0 0 auto;
}

.list-filter-spacer {
  flex: 1;
}

.list-filter-chip,
.list-filter-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
  cursor: pointer;
}

.list-filter-chip:hover,
.list-filter-link:hover {
  border-color: rgba(96, 165, 250, 0.45);
  color: var(--text);
}

/* ============================================================
   テーブル（議員一覧）
   ============================================================ */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.table-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.table-footer-summary {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.table-footer-summary strong {
  color: var(--text);
  font-weight: 700;
}

.table-footer-pager {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.875rem;
}

.table-pager-pages {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

/* ページャーボタン共通 */
.table-pager-btn {
  margin: 0;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.table-pager-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.table-pager-btn:disabled {
  cursor: default;
}

.table-pager-btn--nav {
  font-weight: 700;
  min-width: 3.25rem;
}

.table-pager-btn--nav:not(:disabled):hover {
  background: rgba(0, 0, 0, 0.06);
}

.table-pager-btn--nav:disabled {
  color: var(--muted);
  font-weight: 400;
  opacity: 0.85;
}

.table-pager-btn--page {
  text-transform: none;
  min-width: 2.25rem;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  font-weight: 400;
  color: var(--muted);
}

.table-pager-btn--page:not(:disabled):hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.05);
}

.table-pager-btn--page.is-active {
  color: var(--text);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  opacity: 1;
}

.table-pager-btn--page.is-active:disabled {
  color: var(--text);
  opacity: 1;
  -webkit-text-fill-color: var(--text);
}

.table-parliamentary_group {
  margin: 0 0 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.62rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  cursor: pointer;
}

tr:hover td {
  background: var(--surface-hover);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-open {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.badge-won {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

/* 議員一覧: 営業ステージバッジ（修飾子は member_constants.SALES_STAGE_BADGE_CLASSES） */
.sales-stage-badge {
  display: inline-block;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.sales-stage-badge--untouched {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
}

.sales-stage-badge--contacted {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
}

.sales-stage-badge--negotiating {
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
}

.sales-stage-badge--won {
  background: rgba(34, 197, 94, 0.22);
  color: #86efac;
}

.sales-stage-badge--lost {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* 解約: 紫系（未接触のグレーと区別） */
.sales-stage-badge--cancelled {
  background: rgba(168, 85, 247, 0.25);
  color: #e9d5ff;
}

.prev-match-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.prev-match-badge--needs-review {
  background: rgba(245, 158, 11, 0.28);
  color: #fcd34d;
}

.prev-match-badge--unmatched,
.prev-match-badge--pending {
  background: rgba(148, 163, 184, 0.18);
  color: #94a3b8;
}

.prev-match-badge--linked {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.list-filter-link--alert {
  color: #fcd34d;
  font-weight: 600;
}

.prev-match-card {
  border-color: rgba(245, 158, 11, 0.45);
}

.prev-match-lead {
  margin: 0 0 0.75rem;
  color: var(--text-muted, #94a3b8);
  font-size: 0.9rem;
}

.member-review-section + .member-review-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border, rgba(148, 163, 184, 0.2));
}

.member-review-section-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.member-review-form .actions-bar {
  margin-top: 1rem;
}

.prev-match-candidate-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.prev-match-candidate-label {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(148, 163, 184, 0.25));
  cursor: pointer;
}

.prev-match-candidate-label:hover {
  background: var(--surface-hover, rgba(148, 163, 184, 0.08));
}

.prev-match-candidate-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.prev-match-candidate-meta {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
}

.prev-match-linked-note {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted, #94a3b8);
}

.member-edit-error {
  color: #fca5a5;
  margin: 0 0 0.75rem;
}

.page-lead-text {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted, #94a3b8);
  font-weight: 400;
}

.collect-filter-form {
  margin-bottom: 1rem;
}

.collect-muni-count {
  margin: 0;
  padding: 0.85rem 1rem 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.collect-flash {
  margin-bottom: 0.75rem;
}

.collect-muni-list-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.collect-muni-list-link:hover {
  color: #60a5fa;
  text-decoration: underline;
}

.collect-status-card {
  margin-bottom: 1rem;
}

.collect-last-row-count {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
}

.collect-progress {
  margin: 0.75rem 0 0.35rem;
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.collect-progress__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #6366f1);
  transition: width 0.35s ease;
}

.collect-progress__count {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
}

.collect-progress-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
}

.collect-worker-status {
  font-size: 0.78rem;
  color: #fca5a5;
}

.collect-worker-status.is-active {
  color: #86efac;
}

.collect-status-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}

.collect-status-head h2 {
  margin: 0;
}

.collect-activity-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.collect-activity-badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #38bdf8;
  animation: collect-pulse 1.2s ease-in-out infinite;
}

.collect-status-card--slow .collect-activity-badge {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
}

.collect-status-card--slow .collect-activity-badge::before {
  background: #fbbf24;
}

.collect-status-card--stale .collect-activity-badge,
.collect-status-card--starting .collect-activity-badge {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

.collect-status-card--stale .collect-activity-badge::before,
.collect-status-card--starting .collect-activity-badge::before {
  background: #f87171;
  animation: none;
}

.collect-progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
}

.collect-activity-note {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted, #94a3b8);
}

.collect-activity-note--slow {
  color: #fcd34d;
}

.collect-activity-note--stale,
.collect-activity-note--starting {
  color: #fca5a5;
}

.collect-progress--live .collect-progress__bar {
  position: relative;
  overflow: hidden;
}

.collect-progress--live .collect-progress__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 100%
  );
  animation: collect-shimmer 1.6s ease-in-out infinite;
}

.collect-progress--indeterminate .collect-progress__bar {
  width: 40% !important;
  animation: collect-indeterminate 1.4s ease-in-out infinite;
}

@keyframes collect-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.85);
  }
}

@keyframes collect-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes collect-indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(280%);
  }
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.text-muted {
  color: var(--text-muted, #94a3b8);
}

.list-needs-review-link {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  color: #fcd34d;
  text-decoration: underline;
}

.link-row {
  color: var(--text);
  font-weight: 500;
}

.link-row:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ============================================================
   詳細画面 — グリッド / カード
   ============================================================ */
.detail-grid {
  display: grid;
  gap: 0.8rem;
}

@media (min-width: 720px) {
  .detail-grid {
    grid-template-columns: 1fr 400px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

/* 基本情報・営業状況カード共通の余白調整 */
.card-sales-status {
  padding: 0.95rem 1.05rem;
}

.card-sales-status .info-grid {
  gap: 0.55rem;
}

.card-sales-status .info-row {
  gap: 0.55rem;
}

.card-sales-status .info-card {
  padding: 0.65rem 0.82rem;
}

.card-sales-status .info-label {
  font-size: 0.8rem;
  margin-bottom: 0.45rem;
}

/* 営業ステージのセグメント（横並びピル） */
.sales-stage-segments {
  display: flex;
  gap: 2px;
  padding: 4px;
  margin-bottom: 0.75rem;
  background: #e8eaef;
  border-radius: 10px;
}

.sales-stage-segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0.42rem 0.35rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  color: #64748b;
  text-align: center;
  white-space: nowrap;
  cursor: default;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

label.sales-stage-segment {
  cursor: pointer;
}

.sales-stage-segment-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sales-stage-segment-label {
  pointer-events: none;
}

.sales-stage-segment.is-active,
.sales-stage-segment:has(.sales-stage-segment-input:checked) {
  background: #1a2332;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* ============================================================
   詳細画面 — info-grid / info-card（表示 & 編集共通）
   ============================================================ */
.dl {
  display: grid;
  gap: 0.75rem;
}

.dl-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.dl-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.dl-row dd {
  margin: 0;
}

.info-grid {
  display: grid;
  gap: 0.45rem;
}

.info-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

@media (min-width: 720px) {
  .info-row {
    grid-template-columns: 1fr 1fr;
  }
}

.info-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.48rem 0.72rem;
}

.info-card-full {
  grid-column: 1 / -1;
}

.info-label {
  margin: 0 0 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.info-value {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.info-value-pre {
  white-space: pre-wrap;
  font-weight: 600;
}

.info-value a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.info-value a:hover {
  text-decoration: underline;
}

/* ============================================================
   詳細画面 — 編集フォームの input / select / textarea
   ============================================================ */
.member-contact-form input:not([type="checkbox"]):not([type="radio"]),
.member-detail-edit-form input:not([type="checkbox"]):not([type="radio"]),
.contract-inline-form input:not([type="checkbox"]):not([type="radio"]),
.member-contact-form select,
.member-detail-edit-form select,
.contract-inline-form select,
.member-contact-form textarea,
.member-detail-edit-form textarea,
.contract-inline-form textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  box-sizing: border-box;
}

.member-contact-form input[type="checkbox"],
.member-detail-edit-form input[type="checkbox"],
.contract-inline-form input[type="checkbox"],
.member-contact-form input[type="radio"],
.member-detail-edit-form input[type="radio"],
.contract-inline-form input[type="radio"] {
  width: auto;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.member-detail-edit-form textarea,
.contract-inline-form textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.45;
}

.member-contact-form input:not([type="checkbox"]):not([type="radio"]):focus,
.member-detail-edit-form input:not([type="checkbox"]):not([type="radio"]):focus,
.contract-inline-form input:not([type="checkbox"]):not([type="radio"]):focus,
.member-contact-form select:focus,
.member-detail-edit-form select:focus,
.contract-inline-form select:focus,
.member-contact-form textarea:focus,
.member-detail-edit-form textarea:focus,
.contract-inline-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.contract-inline-form input[type="date"] {
  color-scheme: dark;
}

/* ============================================================
   詳細画面 — 編集モードのレイアウトヘルパー
   ============================================================ */
.member-heading-edit {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}

.member-heading-edit-row {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .member-heading-edit-row--name {
    grid-template-columns: 1fr 1fr;
  }

  .member-heading-edit-row:not(.member-heading-edit-row--name) {
    grid-template-columns: 1fr 1fr;
  }

  .member-heading-edit-row .info-card-full {
    grid-column: 1 / -1;
  }
}

.page-heading-edit-toolbar {
  margin-bottom: 0.65rem;
}

.page-title-edit-hint {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
}

/* フィールドグループ（セクション区切り線付き） */
.member-detail-field-group {
  display: grid;
  gap: 0.45rem;
}

.member-detail-field-group--contact {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.member-detail-field-group--contact-only {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* 議員新規作成 */
.member-create-layout {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.member-create-layout .page-heading {
  justify-content: center;
}

.member-create-layout .page-title {
  text-align: center;
}

.member-create-card {
  width: 100%;
}

/* 保存成功メッセージ */
.member-edit-success {
  margin: 0 0 0.6rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 8px;
  color: #86efac;
  background: rgba(34, 197, 94, 0.1);
  font-size: 0.84rem;
}

/* ============================================================
   活動履歴（接触ログ一覧 + 入力フォーム）
   ============================================================ */
.activity-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

@media (min-width: 900px) {
  .activity-layout {
    grid-template-columns: 1.2fr 1fr;
  }
}

.activity-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.6rem 0.75rem;
}

.activity-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.35rem;
  max-height: 360px;
  overflow-y: auto;
}

.activity-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: var(--surface-hover);
}

.activity-time {
  margin: 0 0 0.3rem;
  font-size: 0.73rem;
  color: var(--muted);
}

.activity-text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text);
}

.activity-compose {
  position: relative;
  margin-top: 0.35rem;
}

.activity-method-select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  margin-bottom: 0.45rem;
}

.activity-method-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.activity-textarea {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-hover);
  color: var(--text);
  padding: 0.7rem 2.5rem 0.7rem 0.75rem;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
}

.activity-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.activity-send-btn {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 1.6rem;
  height: 1.6rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}

.activity-send-btn:hover {
  background: var(--accent-hover);
}

/* ============================================================
   データ確認カード（現行/新規の比較）
   ============================================================ */
.verify-grid {
  display: grid;
  gap: 0.65rem;
}

.verify-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

@media (min-width: 900px) {
  .verify-row {
    grid-template-columns: 140px 1fr 1fr;
    align-items: start;
  }
}

.verify-field-label {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.verify-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-hover);
  padding: 0.48rem 0.6rem;
  min-height: 66px;
}

.verify-card-label {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.verify-card-value {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 600;
}

.verify-card-selected {
  border-color: #60a5fa;
  background: color-mix(in srgb, var(--surface) 86%, #60a5fa 14%);
}

.verify-card-selectable {
  cursor: pointer;
  display: block;
}

.verify-card-selectable .verify-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.verify-card-selectable:has(.verify-radio:checked) {
  border-color: #60a5fa;
  background: color-mix(in srgb, var(--surface) 86%, #60a5fa 14%);
}

.verify-check {
  position: absolute;
  right: 0.55rem;
  top: 0.55rem;
  color: #3b82f6;
  font-size: 0.85rem;
  font-weight: 700;
}

.verify-submit-btn {
  width: auto;
  padding: 0.58rem 1.05rem;
  border-radius: 8px;
  font-size: 0.82rem;
}

/* ============================================================
   ユーティリティ
   ============================================================ */
.detail-span-full {
  grid-column: 1 / -1;
}

.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.actions-bar .btn {
  width: auto;
}

.actions-bar-bottom-center {
  justify-content: center;
  margin-top: 0.6rem;
  margin-bottom: 0;
}

.actions-bar-bottom-edit {
  justify-content: flex-end;
  margin-top: 0.8rem;
  margin-bottom: 0;
}

.empty-state {
  text-align: center;
  padding: 1.8rem 1rem;
  color: var(--muted);
}

/* ============================================================
   契約情報 / ログインアカウント
   ============================================================ */
.contract-status-badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.3;
}

.contract-status-badge--none {
  background: #eef2f7;
  color: #64748b;
}

.contract-status-badge--active {
  background: #dcfce7;
  color: #166534;
}

.contract-status-badge--cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.contract-status-badge--inactive {
  background: #fef3c7;
  color: #92400e;
}

.contract-cms-badge {
  display: inline-block;
  margin-left: 0;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #dbeafe;
  color: #1d4ed8;
}

.contract-cms-badge--off {
  background: #374151;
  color: #9ca3af;
}

a.contract-cms-badge--link {
  text-decoration: none;
  cursor: pointer;
}

a.contract-cms-badge--link:hover {
  background: #bfdbfe;
  text-decoration: underline;
}

.contract-panel-layout {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.8rem;
  align-items: stretch;
}

@media (min-width: 720px) {
  .contract-panel-layout:not(.contract-panel-layout--solo) {
    grid-template-columns: minmax(0, 1fr) minmax(420px, 480px);
  }
}

.contract-panel-layout--solo {
  grid-template-columns: 1fr;
}

.contract-panel-main,
.contract-panel-side {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.contract-panel-main-grid,
.contract-panel-side-grid {
  flex: 1;
}

.contract-panel-side-invite {
  margin-top: 0.55rem;
}

.contract-panel-side .info-value {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
}

.contract-panel-side .contract-portal-url {
  display: inline;
  font-size: inherit;
  font-weight: inherit;
  overflow-wrap: anywhere;
}

.contract-panel-flash {
  grid-column: 1 / -1;
}

.contract-panel-side-email {
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.contract-panel-actions,
.contract-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.contract-form-heading {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.contract-form-help {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.subdomain-feedback {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
}

.subdomain-feedback--ok {
  margin: 0.35rem 0 0;
  color: #6ee7b7;
}

.contract-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.contract-empty-note {
  margin: 0.2rem 0 0.55rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.contract-portal-url {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

.contract-invite-section {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.contract-invite-links {
  margin-top: 0.75rem;
}

.contract-invite-setup-url {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--accent);
  word-break: break-all;
}

.member-edit-error {
  margin: 0 0 0.55rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.86rem;
}

.member-users-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.35rem;
}

.member-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.member-users-table th,
.member-users-table td {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.member-users-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.member-user-state {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}

.member-user-state--invited {
  background: #fef3c7;
  color: #92400e;
}

.member-user-state--active {
  background: #dcfce7;
  color: #166534;
}

.member-user-resend-form {
  margin: 0;
}
