/* ─── リセット ──────────────────────────────────────────────────────────────── */
*, *::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);
}
.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; }

/* ─── ボタン ────────────────────────────────────────────────────────────────── */
.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; }
.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-ghost     { background: transparent; color: #ccc; border: 1px solid #4a5568; }
.btn-ghost:hover     { background: #2d3748; }
.btn-sm        { padding: 5px 12px; font-size: 0.8rem; }

/* ─── ビュー共通 ────────────────────────────────────────────────────────────── */
.view { display: block; min-height: calc(100vh - 54px); }
.view.hidden { display: none; }

/* ─── 一覧画面 ──────────────────────────────────────────────────────────────── */
#view-list { padding: 20px 24px; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.toolbar-left { display: flex; align-items: center; gap: 12px; }
.toolbar-left h1 { font-size: 1.05rem; font-weight: 700; color: #232f3e; }
.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 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; }
th.sorted { color: #ff9900; }
th.sorted::after { content: ' ▲'; font-size: 0.7rem; }
th.sorted[data-dir="desc"]::after { content: ' ▼'; }
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; }
tbody tr.row-alert td { background: #fffbeb; }
tbody tr.row-alert:hover td { background: #fef3c7; }

/* 効果確認日アラートラベル */
.alert-overdue { color: #e53e3e; font-weight: 700; white-space: nowrap; }
.alert-overdue::before { content: '⚠ '; }
.alert-soon { color: #d97706; font-weight: 700; white-space: nowrap; }
.alert-soon::before { content: '🔔 '; }
.td-id { font-family: monospace; font-size: 0.8rem; color: #888; white-space: nowrap; }
.td-product { font-weight: 600; color: #2d3748; max-width: 200px; }
.td-summary { color: #555; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-operator { white-space: nowrap; }
.empty-msg { text-align: center; padding: 48px; color: #aaa; font-size: 0.9rem; }

/* ─── バッジ ────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }

/* モール */
.mall-amazon  { background: #fff3cd; color: #7a4f00; }
.mall-rakuten { background: #ffe4e4; color: #9b1c1c; }
.mall-yahoo   { background: #ede9fe; color: #5b21b6; }
.mall-owned   { background: #d1fae5; color: #065f46; }
.mall-other   { background: #e5e7eb; color: #374151; }

/* ステータス */
.st-pending    { background: #f3f4f6; color: #6b7280; }
.st-done       { background: #dbeafe; color: #1e40af; }
.st-checking   { background: #fef3c7; color: #92400e; }
.st-evaluated  { background: #d1fae5; color: #065f46; }

/* 効果判定 */
.ev-excellent  { background: #d1fae5; color: #065f46; }
.ev-good       { background: #dbeafe; color: #1e40af; }
.ev-partial    { background: #fef3c7; color: #92400e; }
.ev-bad        { background: #fee2e2; color: #991b1b; }
.ev-none       { background: #f3f4f6; color: #9ca3af; }

/* 優先度 */
.pr-high   { background: #fee2e2; color: #991b1b; }
.pr-mid    { background: #fef3c7; color: #92400e; }
.pr-low    { background: #f3f4f6; color: #6b7280; }

/* カテゴリ */
.badge-cat { background: #ede9fe; color: #5b21b6; }

/* ─── フォーム画面 ──────────────────────────────────────────────────────────── */
#view-form { padding: 24px; }
.form-container { max-width: 860px; margin: 0 auto; }

.form-section {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  margin-bottom: 16px; overflow: hidden;
}
.form-section-title {
  background: #f7fafc; border-bottom: 1px solid #e2e8f0;
  padding: 10px 20px; font-size: 0.88rem; font-weight: 700;
  color: #2d3748; display: flex; align-items: center; gap: 8px;
}
.form-section-title .opt { font-size: 0.72rem; font-weight: 400; color: #aaa; background: #eee; padding: 1px 6px; border-radius: 3px; }
.form-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }

.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-full   { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.8rem; font-weight: 600; color: #4a5568; }
.field.required label::after { content: ' *'; color: #e53e3e; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid #cbd5e0; border-radius: 6px;
  font-size: 0.88rem; color: #2d3748; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s; background: #fff;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #ff9900; box-shadow: 0 0 0 2px rgba(255,153,0,0.15);
}
.field input.error, .field select.error, .field textarea.error {
  border-color: #e53e3e; box-shadow: 0 0 0 2px rgba(229,62,62,0.1);
}
.field textarea { resize: vertical; min-height: 72px; }
.field input[type="number"] { -moz-appearance: textfield; }
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* 変更前後の横並びレイアウト */
.before-after-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: relative;
}
.before-after-grid::after {
  content: '→'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: #aaa; font-size: 1.2rem; pointer-events: none;
}

.form-actions { display: flex; gap: 10px; padding: 20px 0 8px; }

/* ─── 詳細画面 ──────────────────────────────────────────────────────────────── */
#view-detail { padding: 24px; }
.detail-container { max-width: 860px; margin: 0 auto; }

.detail-head {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 20px 24px; margin-bottom: 16px;
}
.detail-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.detail-head-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.detail-id   { font-family: monospace; font-size: 0.85rem; color: #888; }
.detail-product { font-size: 1.2rem; font-weight: 700; color: #1a202c; margin-bottom: 4px; }
.detail-meta { font-size: 0.82rem; color: #718096; display: flex; gap: 16px; flex-wrap: wrap; }

.detail-section {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  margin-bottom: 14px; overflow: hidden;
}
.detail-section-title {
  background: #f7fafc; border-bottom: 1px solid #e2e8f0;
  padding: 9px 20px; font-size: 0.85rem; font-weight: 700; color: #2d3748;
}
.detail-body { padding: 16px 20px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.detail-item { padding: 8px 0; border-bottom: 1px solid #f0f0f0; display: flex; gap: 12px; align-items: flex-start; }
.detail-grid .detail-item:nth-last-child(-n+2) { border-bottom: none; }
.detail-item .di-label { font-size: 0.78rem; color: #718096; font-weight: 600; min-width: 110px; flex-shrink: 0; padding-top: 1px; }
.detail-item .di-value { font-size: 0.88rem; color: #2d3748; word-break: break-word; }

.detail-full { padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.detail-full:last-child { border-bottom: none; }
.detail-full .df-label { font-size: 0.78rem; color: #718096; font-weight: 600; margin-bottom: 6px; }
.detail-full .df-value { font-size: 0.88rem; color: #2d3748; white-space: pre-wrap; line-height: 1.65; }

/* 変更前後ボックス */
.ba-grid { display: grid; grid-template-columns: 1fr 40px 1fr; gap: 8px; align-items: center; margin: 12px 0; }
.ba-box { border-radius: 6px; padding: 12px 14px; font-size: 0.88rem; white-space: pre-wrap; line-height: 1.6; min-height: 56px; }
.ba-before { background: #fff5f5; border: 1px solid #fed7d7; color: #742a2a; }
.ba-after  { background: #f0fff4; border: 1px solid #c6f6d5; color: #22543d; }
.ba-arrow  { text-align: center; color: #a0aec0; font-size: 1.2rem; }
.ba-label  { font-size: 0.72rem; font-weight: 700; color: #718096; margin-bottom: 4px; }

/* 数値比較テーブル */
.compare-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.compare-table th { background: #f7fafc; padding: 8px 12px; text-align: left; font-size: 0.78rem; color: #718096; border-bottom: 1px solid #e2e8f0; }
.compare-table td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; }
.compare-table tr:last-child td { border-bottom: none; }
.compare-table .metric { font-weight: 600; color: #4a5568; }
.ch-up   { color: #38a169; font-weight: 700; }
.ch-down { color: #e53e3e; font-weight: 700; }
.ch-flat { color: #718096; }
.no-data { color: #aaa; font-size: 0.85rem; padding: 12px 0; }

/* 評価セクション */
.eval-box { display: flex; gap: 24px; align-items: flex-start; padding: 12px 0; }
.eval-score { font-size: 2.5rem; font-weight: 900; line-height: 1; }
.eval-detail { flex: 1; }
.eval-label { font-size: 0.75rem; color: #718096; margin-bottom: 2px; }
.eval-text { font-size: 0.88rem; color: #2d3748; margin-bottom: 8px; }

/* ─── スクロールバー ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f0f2f5; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* ─── ユーティリティ ────────────────────────────────────────────────────────── */
.mt-8 { margin-top: 8px; }
.text-muted { color: #a0aec0; }
.divider { border: none; border-top: 1px solid #e2e8f0; margin: 12px 0; }
