/* ─── リセット ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', sans-serif; background: #f0f2f5; color: #333; font-size: 14px; line-height: 1.5; }

/* ─── ヘッダー（共通） ──────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: #232f3e; color: #fff;
  height: 54px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { font-size: 0.85rem; color: #ff9900; font-weight: 700; text-decoration: none; letter-spacing: 0.5px; }
.header-sep { color: #4a5568; font-size: 0.9rem; }
.header-title { font-size: 0.95rem; font-weight: 600; color: #e2e8f0; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-user { font-size: 0.78rem; color: #a0aec0; }

/* ─── ボタン ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 6px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer; border: none;
  transition: background 0.15s, box-shadow 0.15s; text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: #ff9900; color: #fff; }
.btn-primary:hover   { background: #e68a00; }
.btn-secondary { background: #fff; color: #444; border: 1px solid #ccc; }
.btn-secondary:hover { background: #f5f5f5; }
.btn-danger    { background: #e53e3e; color: #fff; }
.btn-danger:hover    { background: #c53030; }
.btn-success   { background: #276749; color: #fff; }
.btn-success:hover   { background: #1e5237; }
.btn-info      { background: #2b6cb0; color: #fff; }
.btn-info:hover      { background: #2c5282; }
.btn-ghost     { background: transparent; color: #ccc; border: 1px solid #4a5568; }
.btn-ghost:hover     { background: #2d3748; }
.btn-sm        { padding: 5px 12px; font-size: 0.8rem; }
.btn:disabled  { opacity: 0.5; cursor: not-allowed; }

/* ─── ビュー共通 ─────────────────────────────────────────────────────────────── */
.view { display: block; min-height: calc(100vh - 54px); }
.view.hidden { display: none; }

/* ─── トースト通知 ───────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #2d3748; color: #fff;
  padding: 10px 22px; border-radius: 8px; font-size: 0.88rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25); z-index: 9999;
  transition: opacity 0.3s; opacity: 0; pointer-events: none;
}
#toast.show { opacity: 1; }
#toast.toast-ok    { background: #276749; }
#toast.toast-error { background: #9b2c2c; }

/* ─── ツールバー ──────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-left h1 { font-size: 1.05rem; font-weight: 700; color: #232f3e; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.count-badge { background: #edf2f7; color: #555; border-radius: 20px; padding: 2px 10px; font-size: 0.78rem; font-weight: 600; }

/* ─── フィルターバー ─────────────────────────────────────────────────────────── */
.filter-bar {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 12px 16px; margin-bottom: 16px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.filter-bar label { display: block; font-size: 0.75rem; font-weight: 600; color: #666; margin-bottom: 3px; }
.filter-bar input[type="text"],
.filter-bar input[type="date"],
.filter-bar select {
  padding: 6px 10px; border: 1px solid #ccc; border-radius: 5px;
  font-size: 0.83rem; color: #333; background: #fff; min-width: 120px;
}
.filter-bar input[type="text"] { min-width: 200px; }
.filter-bar input:focus, .filter-bar select:focus {
  outline: none; border-color: #ff9900; box-shadow: 0 0 0 2px rgba(255,153,0,0.15);
}
.filter-item { display: flex; flex-direction: column; }
.filter-reset { align-self: flex-end; }

/* ─── テーブル ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0; font-size: 0.84rem; }
thead { background: #2d3748; color: #e2e8f0; }
th { padding: 10px 12px; text-align: left; font-weight: 600; font-size: 0.78rem; white-space: nowrap; user-select: none; }
th[data-sort] { cursor: pointer; }
th[data-sort]:hover { background: #374151; }
td { padding: 9px 12px; border-bottom: 1px solid #edf2f7; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover td { background: #fef9f0; }
.td-title { font-weight: 600; color: #2d3748; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-msg { text-align: center; padding: 48px; color: #aaa; font-size: 0.9rem; line-height: 2; }

/* ─── ページ内レイアウト ─────────────────────────────────────────────────────── */
.page-inner { padding: 20px 24px; }

/* ─── 反映ステータスバッジ ───────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 12px;
  font-size: 0.73rem; font-weight: 700; white-space: nowrap;
}
.badge-pending  { background: #fef9c3; color: #854d0e; }
.badge-done     { background: #dcfce7; color: #166534; }
.badge-failed   { background: #fee2e2; color: #991b1b; }
.badge-ec       { background: #dbeafe; color: #1e40af; }
.badge-sb       { background: #f3e8ff; color: #6b21a8; }
.badge-other    { background: #f1f5f9; color: #475569; }
.badge-draft    { background: #fef3c7; color: #92400e; }
.badge-saved    { background: #d1fae5; color: #065f46; }

/* ─── 議事録カード（一覧） ───────────────────────────────────────────────────── */
.minutes-table-row td:first-child { font-weight: 600; }
.reflect-summary { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.reflect-num { font-size: 0.8rem; font-weight: 700; }
.reflect-done { color: #166534; }
.reflect-pending { color: #854d0e; }

/* ─── 作成・編集フォーム ─────────────────────────────────────────────────────── */
.form-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 24px; margin-bottom: 16px;
}
.form-card h2 { font-size: 0.95rem; font-weight: 700; color: #232f3e; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid #f0f2f5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.col3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.col1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.span2 { grid-column: span 2; }
.form-group.span3 { grid-column: span 3; }
.form-group label { font-size: 0.78rem; font-weight: 600; color: #4a5568; }
.form-group label .req { color: #e53e3e; margin-left: 2px; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px;
  font-size: 0.88rem; color: #333; background: #fff;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: #ff9900; box-shadow: 0 0 0 2px rgba(255,153,0,0.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.74rem; color: #888; margin-top: 2px; }

/* 原文入力エリア */
.source-input { min-height: 200px; font-family: monospace; font-size: 0.83rem; line-height: 1.7; }
.file-drop-zone {
  border: 2px dashed #cbd5e0; border-radius: 8px; padding: 20px;
  text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s;
  background: #f8fafc; margin-top: 8px;
}
.file-drop-zone:hover, .file-drop-zone.dragover { border-color: #ff9900; background: #fffbf0; }
.file-drop-zone p { color: #888; font-size: 0.83rem; }

/* ─── フォームアクションバー ─────────────────────────────────────────────────── */
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 16px 0 0; border-top: 1px solid #e2e8f0; margin-top: 16px; flex-wrap: wrap; }

/* ─── 候補カード ─────────────────────────────────────────────────────────────── */
.candidates-section { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.candidates-section h2 { font-size: 0.95rem; font-weight: 700; color: #232f3e; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid #f0f2f5; display: flex; align-items: center; gap: 10px; }
.candidate-card {
  border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px;
  margin-bottom: 10px; background: #fafafa; transition: border-color 0.15s;
}
.candidate-card:hover { border-color: #cbd5e0; }
.candidate-card.reflected { border-left: 4px solid #276749; }
.candidate-card.failed    { border-left: 4px solid #e53e3e; }
.candidate-card.pending   { border-left: 4px solid #d97706; }
.candidate-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.candidate-title { font-weight: 700; color: #2d3748; font-size: 0.9rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.candidate-body  { font-size: 0.83rem; color: #555; margin-bottom: 8px; line-height: 1.6; }
.candidate-source { font-size: 0.78rem; color: #888; background: #f1f5f9; padding: 6px 10px; border-radius: 4px; margin-bottom: 8px; white-space: pre-wrap; word-break: break-all; }
.candidate-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.candidate-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.reflect-info { margin-top: 8px; font-size: 0.78rem; color: #555; background: #f0fdf4; padding: 6px 10px; border-radius: 4px; }
.reflect-info a { color: #2b6cb0; text-decoration: underline; }
.reflect-error { margin-top: 8px; font-size: 0.78rem; color: #9b2c2c; background: #fff5f5; padding: 6px 10px; border-radius: 4px; }

/* ─── 統計バー ───────────────────────────────────────────────────────────────── */
.stats-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 10px 20px; text-align: center; min-width: 110px;
}
.stat-card .num { font-size: 1.4rem; font-weight: 700; color: #232f3e; }
.stat-card .lbl { font-size: 0.72rem; color: #888; }
.stat-card.done-stat .num { color: #276749; }
.stat-card.pending-stat .num { color: #d97706; }
.stat-card.failed-stat .num  { color: #e53e3e; }

/* ─── 詳細ビュー ─────────────────────────────────────────────────────────────── */
.detail-section { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.detail-section h2 { font-size: 0.95rem; font-weight: 700; color: #232f3e; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid #f0f2f5; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.meta-item label { font-size: 0.74rem; font-weight: 600; color: #888; display: block; margin-bottom: 2px; }
.meta-item .val  { font-size: 0.88rem; color: #2d3748; font-weight: 500; }
.source-text { font-size: 0.83rem; color: #555; background: #f8fafc; padding: 14px; border-radius: 6px; white-space: pre-wrap; word-break: break-all; max-height: 300px; overflow-y: auto; line-height: 1.7; border: 1px solid #e2e8f0; }
.text-area-field { font-size: 0.88rem; color: #333; line-height: 1.7; white-space: pre-wrap; word-break: break-all; }

/* ─── 履歴 ───────────────────────────────────────────────────────────────────── */
.history-list { list-style: none; }
.history-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf2f7; font-size: 0.82rem; }
.history-item:last-child { border-bottom: none; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: #a0aec0; flex-shrink: 0; margin-top: 5px; }
.history-dot.create { background: #276749; }
.history-dot.update { background: #2b6cb0; }
.history-dot.reflect { background: #6b21a8; }
.history-dot.candidate { background: #d97706; }
.history-body { flex: 1; }
.history-action { font-weight: 600; color: #2d3748; }
.history-by { color: #888; margin-left: 6px; }
.history-at { color: #aaa; font-size: 0.76rem; margin-top: 2px; }
.history-diff { color: #555; margin-top: 4px; font-size: 0.78rem; white-space: pre-wrap; word-break: break-all; }

/* ─── 反映確認ビュー ─────────────────────────────────────────────────────────── */
.review-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 18px; margin-bottom: 12px;
}
.review-card .review-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.review-card .review-source { font-size: 0.78rem; color: #888; background: #f1f5f9; padding: 6px 10px; border-radius: 4px; margin-bottom: 10px; white-space: pre-wrap; word-break: break-all; }
.review-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.review-fields .full { grid-column: span 2; }
.review-toggle { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.toggle-switch { position: relative; width: 36px; height: 20px; cursor: pointer; }
.toggle-switch input { display: none; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 20px; background: #ccc;
  transition: background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: #ff9900; }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.toggle-switch input:checked ~ .toggle-thumb { transform: translateX(16px); }
.skip-label { color: #888; text-decoration: line-through; }

/* ─── ローディング ───────────────────────────────────────────────────────────── */
.loading { text-align: center; padding: 40px; color: #888; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid #e2e8f0; border-top-color: #ff9900; border-radius: 50%; animation: spin 0.7s linear infinite; margin-bottom: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── モーダル（候補編集） ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 500;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 10px; padding: 28px;
  width: 540px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-box h3 { font-size: 1rem; font-weight: 700; color: #232f3e; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 1px solid #e2e8f0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; padding-top: 14px; border-top: 1px solid #e2e8f0; }

/* ─── レスポンシブ ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.col3 { grid-template-columns: 1fr; }
  .form-group.span2, .form-group.span3 { grid-column: span 1; }
  .review-fields { grid-template-columns: 1fr; }
  .review-fields .full { grid-column: span 1; }
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .page-inner { padding: 14px 14px; }
}
