/* ─── リセット・基本 ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: #f0f2f5; color: #1a202c; min-height: 100vh; display: flex; flex-direction: column; }

/* ─── ヘッダー（共通） ───────────────────────────────────────────────────────── */
.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; }

/* ─── メインコンテンツ ───────────────────────────────────────────────────────── */
.main { flex: 1; padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ─── ステータスカード ───────────────────────────────────────────────────────── */
.status-bar {
  background: #fff;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.status-section { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 200px; }
.status-item { text-align: center; }
.status-item .label { font-size: 0.7rem; color: #718096; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.status-item .value { font-size: 1.4rem; font-weight: 700; color: #232f3e; }
.status-item .value.highlight { color: #ff9900; }
.status-divider { width: 1px; height: 40px; background: #e2e8f0; }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
}
.status-badge.completed { background: #c6f6d5; color: #276749; }
.status-badge.running   { background: #bee3f8; color: #2a69ac; }
.status-badge.failed    { background: #fed7d7; color: #9b2c2c; }
.status-badge.completed_with_error { background: #fefcbf; color: #744210; }
.status-badge.none      { background: #e2e8f0; color: #4a5568; }

.status-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ─── ボタン ──────────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 18px; border-radius: 6px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; border: none; transition: background 0.15s, opacity 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: #ff9900; color: #fff; }
.btn-primary:hover { background: #e68a00; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger  { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-ghost   { background: transparent; color: #718096; border: 1px solid #e2e8f0; }
.btn-ghost:hover { background: #f7fafc; }

/* ─── タブ ────────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  background: none; border: none; color: #718096;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: #232f3e; }
.tab-btn.active { color: #ff9900; border-bottom-color: #ff9900; }
.tab-btn .badge {
  display: inline-block; background: #ff9900; color: #fff;
  font-size: 0.7rem; padding: 1px 7px; border-radius: 10px; margin-left: 6px;
}
.tab-btn .badge.gray { background: #a0aec0; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── フィルターバー ─────────────────────────────────────────────────────────── */
.filter-bar {
  background: #fff; border-radius: 8px; padding: 14px 20px;
  margin-bottom: 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.filter-bar label { font-size: 0.8rem; color: #4a5568; font-weight: 600; }
.filter-bar select, .filter-bar input[type="text"] {
  padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 0.85rem; background: #f7fafc; color: #2d3748;
}
.filter-bar select:focus, .filter-bar input:focus { outline: 2px solid #ff9900; border-color: transparent; }
.filter-count { margin-left: auto; font-size: 0.8rem; color: #718096; }

/* ─── テーブル ────────────────────────────────────────────────────────────────── */
.table-wrap { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead { background: #f7fafc; }
th { padding: 12px 14px; text-align: left; font-size: 0.75rem; font-weight: 700; color: #4a5568; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ─── テーブル内バッジ・値 ──────────────────────────────────────────────────── */
.profit-rate {
  font-weight: 700; font-size: 0.95rem;
}
.profit-rate.good  { color: #276749; }
.profit-rate.ok    { color: #744210; }
.profit-rate.bad   { color: #9b2c2c; }

.volatility { font-size: 0.85rem; }
.volatility.stable  { color: #276749; }
.volatility.warning { color: #744210; }
.volatility.danger  { color: #9b2c2c; }

.rank { font-size: 0.8rem; color: #4a5568; }
.rank.good { color: #276749; font-weight: 600; }

.pass-badge  { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; }
.pass-badge.pass   { background: #c6f6d5; color: #276749; }
.pass-badge.reject { background: #fed7d7; color: #9b2c2c; }
.pass-badge.unknown { background: #e2e8f0; color: #718096; }

.product-name { font-weight: 600; color: #232f3e; max-width: 240px; }
.product-name a { color: #146eb4; text-decoration: none; }
.product-name a:hover { text-decoration: underline; }
.sub-text { font-size: 0.75rem; color: #a0aec0; margin-top: 2px; }

.price { font-weight: 600; }
.reasons { font-size: 0.75rem; color: #9b2c2c; max-width: 200px; }
.reasons li { list-style: none; padding: 1px 0; }
.reasons li::before { content: '✗ '; }

.amazon-link { color: #ff9900; text-decoration: none; font-size: 0.8rem; font-weight: 600; }
.amazon-link:hover { text-decoration: underline; }
.sd-link { color: #146eb4; text-decoration: none; font-size: 0.8rem; }
.sd-link:hover { text-decoration: underline; }

/* ─── ログテーブル ────────────────────────────────────────────────────────────── */
.log-row td:first-child { font-size: 0.78rem; color: #4a5568; }
.trigger-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 600;
}
.trigger-badge.manual    { background: #ebf8ff; color: #2a69ac; }
.trigger-badge.scheduler { background: #f0fff4; color: #276749; }

/* ─── 空状態 ──────────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: #a0aec0;
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ─── スピナー ────────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── トースト通知 ────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: #232f3e; color: #fff; padding: 12px 20px;
  border-radius: 8px; font-size: 0.85rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: #e53e3e; }

/* ─── プログレスバー（実行中） ───────────────────────────────────────────────── */
.progress-bar-wrap {
  height: 4px; background: #e2e8f0; border-radius: 2px; overflow: hidden; margin-top: 8px;
}
.progress-bar {
  height: 100%; background: #ff9900; border-radius: 2px;
  animation: progress-indeterminate 1.5s infinite;
}
@keyframes progress-indeterminate {
  0%   { transform: translateX(-100%); width: 60%; }
  100% { transform: translateX(200%); width: 60%; }
}
