*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── ライブ価格更新 ── */
@keyframes flash-up {
  0%   { background-color: transparent; }
  25%  { background-color: rgba(22, 163, 74, 0.25); }
  100% { background-color: transparent; }
}
@keyframes flash-down {
  0%   { background-color: transparent; }
  25%  { background-color: rgba(220, 38, 38, 0.25); }
  100% { background-color: transparent; }
}
.price-flash-up   { animation: flash-up   0.9s ease-out; }
.price-flash-down { animation: flash-down 0.9s ease-out; }

.live-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.live-badge-active {
  color: #16a34a;
}
.live-badge-active::before {
  content: "● ";
  font-size: 0.65rem;
}

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --header-bg: #1a2744;
  --header-text: #ffffff;
  --buy: #16a34a;
  --sell: #dc2626;
  --up: #16a34a;
  --down: #dc2626;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0.65rem 0;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.logo { font-size: 1.2rem; font-weight: 700; color: #fff; text-decoration: none; flex-shrink: 0; }
.header-date { font-size: 0.8rem; opacity: 0.7; margin-left: auto; white-space: nowrap; }

/* Search */
.search-form { display: flex; flex: 1; max-width: 400px; }
.search-input {
  flex: 1;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.3);
  border-right: none;
  border-radius: 4px 0 0 4px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 0.85rem;
  outline: none;
}
.search-input::placeholder { color: rgba(255,255,255,0.5); }
.search-input:focus { background: rgba(255,255,255,0.2); }
.search-btn {
  padding: 0.35rem 0.85rem;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 0 4px 4px 0;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.search-btn:hover { background: rgba(255,255,255,0.3); }

/* Main */
main.container { flex: 1; padding-top: 1.25rem; padding-bottom: 2rem; }

/* No-data */
.no-data-banner {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  line-height: 2.2;
}
.no-data-banner code {
  display: inline-block;
  background: #f0f4f8;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  color: var(--text);
}

/* Summary bar */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}
.summary-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0.15rem;
}
.summary-value { font-size: 1.3rem; font-weight: 700; }
.summary-change { font-size: 0.8rem; margin-top: 0.1rem; }
.summary-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }
.sep { color: var(--text-muted); }

/* Market heading */
.market-heading {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.6rem;
  margin-top: 1.25rem;
}

/* Two-column grid */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}
.card-title.buy { border-color: var(--buy); color: var(--buy); }
.card-title.sell { border-color: var(--sell); color: var(--sell); }

/* Table */
.stock-table { width: 100%; border-collapse: collapse; }
.stock-table th {
  text-align: left;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.stock-table th.num, .stock-table td.num { text-align: right; }
.stock-table td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.stock-table tr:last-child td { border-bottom: none; }

.ticker { font-weight: 600; font-family: monospace; font-size: 0.85rem; white-space: nowrap; }
.name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sector { font-size: 0.75rem; color: var(--text-muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* Colors */
.up   { color: var(--up);   font-weight: 600; }
.down { color: var(--down); font-weight: 600; }

/* Empty state */
.empty-message { color: var(--text-muted); text-align: center; padding: 1.5rem; }

/* Footer / meta */
.generated-at { text-align: right; font-size: 0.7rem; color: var(--text-muted); margin-top: 0.75rem; }
.badge-delayed {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 3px;
  padding: 0 0.4rem;
  font-size: 0.7rem;
}
.site-footer { background: var(--header-bg); color: rgba(255,255,255,0.45); padding: 0.75rem 0; text-align: center; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge.prime  { background: #dbeafe; color: #1e40af; }
.badge.growth { background: #dcfce7; color: #166534; }

/* Page header */
.page-header { margin-bottom: 1rem; }
.page-title { font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 0.75rem; }
.result-count { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }

/* Search results table */
.search-table .name-wide { max-width: 240px; }
.search-table .market-label { white-space: nowrap; }
.detail-link { color: #2563eb; text-decoration: none; font-size: 0.8rem; white-space: nowrap; }
.detail-link:hover { text-decoration: underline; }

/* Stock detail */
.breadcrumb { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 1rem; }
.breadcrumb a { color: #2563eb; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.detail-name { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.35rem; }
.detail-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.detail-price-block { text-align: right; flex-shrink: 0; }
.detail-current-price { font-size: 1.8rem; font-weight: 700; }
.detail-change { font-size: 1rem; font-weight: 600; margin-top: 0.1rem; }
.detail-prev-close { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.metric-label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 0.2rem; }
.metric-value { font-size: 1rem; font-weight: 600; }

.chart-card { margin-bottom: 1rem; }
.chart-wrap { height: 260px; }

.history-table .num { font-variant-numeric: tabular-nums; }

/* Sector stats table */
.sector-table .sector-name { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--text-muted); font-weight: 400; }

/* Signal ranking table */
.signal-rank-table .sig-tags-cell { max-width: 160px; }
.sig-tags-cell { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.sig-tag {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.score-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.score-badge.bullish { background: #dcfce7; color: #166534; }
.score-badge.bearish { background: #fee2e2; color: #991b1b; }
.score-badge.neutral  { background: #f1f5f9; color: var(--text-muted); }

/* Sector links */
.sector-link { color: inherit; text-decoration: none; }
.sector-link:hover { color: #2563eb; text-decoration: underline; }

/* Sector detail page */
.sector-stats-block { text-align: right; flex-shrink: 0; }
.sector-stat-row { display: flex; align-items: center; gap: 0.4rem; justify-content: flex-end; margin-bottom: 0.3rem; font-size: 0.82rem; }
.stat-label { color: var(--text-muted); }
.stat-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-sep { color: var(--text-muted); }

.sector-stocks-table .rank-num { color: var(--text-muted); font-size: 0.75rem; width: 2rem; }
.sector-stocks-table tr.row-bullish { background: #f0fdf4; }
.sector-stocks-table tr.row-bearish { background: #fff5f5; }

/* Technical Signals */
.signals-card { margin-bottom: 1rem; }

.signal-summary {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.sig-count {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.sig-count.bullish { background: #dcfce7; color: #166534; }
.sig-count.bearish { background: #fee2e2; color: #991b1b; }
.sig-count.neutral  { background: #f1f5f9; color: var(--text-muted); font-weight: 400; }

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}
.signal-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 0.9rem;
  background: var(--surface);
}
.signal-card.triggered.bullish { border-left-color: var(--up); }
.signal-card.triggered.bearish { border-left-color: var(--down); }
.signal-card.triggered { background: #fafeff; }

.sig-name {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.sig-status {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.sig-status.bullish.strong   { background: #166534; color: #fff; }
.sig-status.bullish.moderate { background: #dcfce7; color: #166534; }
.sig-status.bullish.weak     { background: #f0fdf4; color: #4ade80; border: 1px solid #bbf7d0; }
.sig-status.bearish.strong   { background: #991b1b; color: #fff; }
.sig-status.bearish.moderate { background: #fee2e2; color: #991b1b; }
.sig-status.bearish.weak     { background: #fff1f1; color: #ef4444; border: 1px solid #fecaca; }
.sig-status.neutral          { background: #f1f5f9; color: var(--text-muted); }

.sig-value {
  font-size: 0.72rem;
  font-family: monospace;
  color: var(--text);
  margin-bottom: 0.3rem;
  line-height: 1.5;
}
.sig-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.45;
}

@media (max-width: 900px) {
  .signal-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .signal-grid { grid-template-columns: 1fr; }
}

/* ── Header right nav ── */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  flex-shrink: 0;
}
.header-date { font-size: 0.78rem; opacity: 0.7; white-space: nowrap; }
.nav-link { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 0.82rem; white-space: nowrap; }
.nav-link:hover { color: #fff; }
.nav-link-register {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.2rem 0.65rem;
  border-radius: 4px;
}
.nav-link-register:hover { background: rgba(255,255,255,0.25); }
.username-badge { font-size: 0.78rem; color: rgba(255,255,255,0.65); }
.logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.75);
  padding: 0.18rem 0.55rem;
  border-radius: 3px;
  font-size: 0.75rem;
  cursor: pointer;
}
.logout-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ── Auth forms ── */
.auth-page { max-width: 440px; margin: 3rem auto; }
.add-tx-page { display: flex; justify-content: center; margin-top: 1rem; width: 100%; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
}
.auth-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.5rem; text-align: center; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text-muted); }
.form-input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
  outline: none;
  background: var(--surface);
  color: var(--text);
}
.form-input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.12); }
.form-submit {
  width: 100%;
  padding: 0.6rem;
  background: var(--header-bg);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.form-submit:hover { background: #243052; }
.form-link { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-top: 1rem; }
.form-link a { color: #2563eb; }
.auth-error {
  background: #fee2e2; border: 1px solid #fecaca; border-radius: 4px;
  padding: 0.65rem 0.9rem; margin-bottom: 1rem; font-size: 0.82rem; color: #991b1b;
}
.auth-errors {
  background: #fee2e2; border: 1px solid #fecaca; border-radius: 4px;
  padding: 0.65rem 0.9rem 0.65rem 1.5rem; margin-bottom: 1rem; font-size: 0.82rem; color: #991b1b;
}

/* ── Buttons ── */
.btn-primary {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: var(--header-bg);
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.btn-primary:hover { background: #243052; }
.btn-secondary {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
}
.btn-secondary:hover { background: var(--bg); }

/* ── Portfolio: add form ── */
.radio-group { display: flex; gap: 1.5rem; padding: 0.35rem 0; }
.radio-label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; font-size: 0.85rem; }
.stock-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.45rem;
  padding: 0.45rem 0.75rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  font-size: 0.82rem;
}
.preview-name { font-weight: 600; color: var(--text); }
.preview-price { color: var(--text-muted); }

/* 銘柄名サジェストドロップダウン */
.suggest-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.active { background: #f0f4ff; }
.suggest-code {
  font-family: monospace;
  font-weight: 600;
  color: var(--header-bg);
  min-width: 3rem;
}
.suggest-name { flex: 1; color: var(--text); }
.suggest-sector { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }
.total-display {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* ── Portfolio: dashboard ── */
.portfolio-table td, .portfolio-table th { font-size: 0.82rem; }
.tx-table td, .tx-table th { font-size: 0.82rem; }
.memo-cell { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.badge-tx {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge-tx.buy  { background: #dcfce7; color: #166534; }
.badge-tx.sell { background: #fee2e2; color: #991b1b; }
.delete-btn {
  background: none;
  border: 1px solid #fca5a5;
  color: #dc2626;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.7rem;
  cursor: pointer;
}
.delete-btn:hover { background: #fee2e2; }

/* ── バックフィルパネル ── */
.backfill-panel {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
}
.backfill-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .5rem;
  color: #0c4a6e;
}
.backfill-log {
  font-family: monospace;
  font-size: .75rem;
  background: #fff;
  border: 1px solid #e0f2fe;
  border-radius: 4px;
  padding: .5rem .75rem;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre;
  color: #374151;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #bae6fd;
  border-top-color: #0ea5e9;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}

/* ── シグナル評価ページ ── */

/* 総合サマリー：buy / sell を横並び */
.eval-overall-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 768px) { .eval-overall-wrap { grid-template-columns: 1fr; } }
.eval-overall-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
}
.eval-overall-block.buy  { border-top: 3px solid var(--buy); }
.eval-overall-block.sell { border-top: 3px solid var(--sell); }
.eval-overall-title {
  font-size: .82rem; font-weight: 700;
  margin-bottom: .5rem;
}
.eval-overall-title.buy  { color: var(--buy); }
.eval-overall-title.sell { color: var(--sell); }
.eval-summary-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.eval-summary-table th {
  text-align: left; color: var(--text-muted);
  font-weight: 500; padding: .2rem .4rem; border-bottom: 1px solid var(--border);
}
.eval-summary-table td { padding: .3rem .4rem; }
.eval-summary-table tr:nth-child(even) { background: var(--bg); }

/* 日別：保有期間サマリーバー */
.eval-period-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  background: var(--bg);
  border-radius: 6px;
  padding: .5rem .75rem;
  margin-bottom: .75rem;
  font-size: .75rem;
}
.eval-period-label { font-weight: 600; color: var(--text-muted); min-width: 2rem; }
.eval-period-cell  { text-align: center; min-width: 60px; }
.eval-period-name  { color: var(--text-muted); font-size: .68rem; margin-bottom: .1rem; }
.eval-period-hit   { font-size: .9rem; font-weight: 700; }
.eval-period-ret   { font-size: .68rem; }

/* 折り畳み詳細 */
.eval-details { margin-top: .5rem; }
.eval-details-summary {
  cursor: pointer;
  font-size: .78rem;
  color: var(--text-muted);
  padding: .3rem 0;
  user-select: none;
}
.eval-details-summary:hover { color: var(--text); }
.eval-details[open] .eval-details-summary { margin-bottom: .75rem; }

.eval-notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: .6rem 1rem;
  font-size: .82rem;
  color: #92400e;
  margin-bottom: 1rem;
}
.eval-overall {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.eval-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1.25rem;
  min-width: 140px;
  text-align: center;
}
.eval-stat-label { font-size: .72rem; color: var(--text-muted); margin-bottom: .25rem; }
.eval-stat-value { font-size: 1.4rem; font-weight: 700; }
.eval-stat-sub   { font-size: .75rem; margin-top: .15rem; }

.eval-day-card   { margin-bottom: 1.25rem; }
.eval-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .75rem;
}
.eval-day-title  { font-size: 1rem; font-weight: 700; }
.eval-day-stats  { display: flex; gap: .75rem; flex-wrap: wrap; }
.eval-day-stat   { font-size: .78rem; padding: .2rem .55rem; border-radius: 4px; }
.eval-day-stat.buy  { background: #dcfce7; color: #166534; }
.eval-day-stat.sell { background: #fee2e2; color: #991b1b; }

.eval-tables     { display: flex; flex-direction: column; gap: 1rem; }
.eval-table-title {
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: .35rem;
  padding-left: .25rem;
  border-left: 3px solid;
}
.eval-table-title.buy  { color: var(--buy);  border-color: var(--buy); }
.eval-table-title.sell { color: var(--sell); border-color: var(--sell); }

.eval-table td, .eval-table th { font-size: .78rem; }
.eval-table th.center, .eval-table td.center { text-align: center; }

tr.eval-hit  { background: rgba(22,163,74,.04); }
tr.eval-miss { background: rgba(220,38,38,.04); }

.eval-hit-badge  {
  display: inline-block;
  color: #fff;
  background: var(--buy);
  border-radius: 50%;
  width: 1.3em; height: 1.3em;
  line-height: 1.3em;
  text-align: center;
  font-size: .75rem;
  font-weight: 700;
}
.eval-miss-badge {
  display: inline-block;
  color: #fff;
  background: var(--sell);
  border-radius: 50%;
  width: 1.3em; height: 1.3em;
  line-height: 1.3em;
  text-align: center;
  font-size: .75rem;
  font-weight: 700;
}

/* ── シグナル評価ページ ── */

/* 総合統計 */
.eval-summary-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.eval-summary-block {
  flex: 1 1 320px;
  overflow: hidden;
  padding: 0;
}
.eval-summary-heading {
  padding: .6rem 1rem;
  font-size: .85rem;
  font-weight: 700;
}
.eval-summary-heading.buy  { background: #dcfce7; color: #166534; }
.eval-summary-heading.sell { background: #fee2e2; color: #991b1b; }
.eval-summary-body {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1rem;
  flex-wrap: wrap;
}
.eval-summary-kpis {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  flex: 1;
}
.eval-kpi-item  { text-align: center; min-width: 52px; }
.eval-kpi-val   { font-size: 1.45rem; font-weight: 800; line-height: 1.1; }
.eval-kpi-lbl   { font-size: .68rem; color: var(--text-muted); margin-top: .15rem; }

/* ドーナツチャート */
.eval-donut-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}
.eval-donut-wrap canvas { width: 110px !important; height: 110px !important; }
.eval-donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.35;
  pointer-events: none;
}

/* 日別チャートカード */
.eval-daily-chart-card { padding: 1rem; margin-bottom: 1.25rem; }

/* 日別詳細アコーディオン */
.eval-day-details {
  margin-bottom: .85rem;
  padding: 0;
  overflow: hidden;
}
.eval-day-details > summary { list-style: none; }
.eval-day-details > summary::-webkit-details-marker { display: none; }
.eval-day-summary {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .75rem 1rem;
  cursor: pointer;
  user-select: none;
}
.eval-day-summary:hover { background: #f8fafc; }
.eval-day-date  { font-weight: 700; font-size: .9rem; }
.eval-day-badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.eval-smart-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 4px;
  white-space: nowrap;
}
.eval-smart-badge.buy  { background: #dcfce7; color: #166534; }
.eval-smart-badge.sell { background: #fee2e2; color: #991b1b; }

.eval-day-content { padding: .75rem 1rem 1rem; border-top: 1px solid var(--border); }

/* テーブルとページネーション */
.eval-table-wrap { margin-bottom: .5rem; }
.eval-page-nav {
  display: flex;
  align-items: center;
  gap: .75rem;
  justify-content: flex-end;
  padding: .45rem .25rem 0;
}
.eval-page-btn {
  padding: .25rem .7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-size: .78rem;
  cursor: pointer;
}
.eval-page-btn:hover:not(:disabled) { background: #f1f5f9; }
.eval-page-btn:disabled { opacity: .4; cursor: default; }
.eval-page-info { font-size: .75rem; color: var(--text-muted); }

/* 出口理由バッジ */
.eval-exit-reason {
  display: inline-block;
  font-size: .6rem;
  padding: .05rem .25rem;
  border-radius: 3px;
  margin-left: .2rem;
  vertical-align: middle;
}
.eval-exit-reason.flip { background: #fef9c3; color: #854d0e; }
.eval-exit-reason.hold { background: #f1f5f9; color: var(--text-muted); }

.eval-profit-cell { font-weight: 700; }
.eval-total-row { background: #f8fafc; border-top: 2px solid var(--border); font-weight: 600; }
.eval-total-row td { padding-top: .45rem; padding-bottom: .45rem; }

/* Responsive */
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .grid-2col { grid-template-columns: 1fr; }
  .name { max-width: 90px; }
  .detail-header { flex-direction: column; }
  .detail-price-block { text-align: left; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .header-date { display: none; }
  .search-form { max-width: none; }
  .eval-summary-row { flex-direction: column; }
  .eval-donut-wrap  { display: none; }
}

/* ── 設定パネル ── */
.eval-settings-details { padding: 0; overflow: hidden; margin-bottom: 1rem; }
.eval-settings-summary {
  list-style: none;
  padding: .7rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--text-muted);
}
.eval-settings-summary::-webkit-details-marker { display: none; }
.eval-settings-summary::before { content: "▶"; font-size: .65rem; transition: transform .2s; }
details[open] > .eval-settings-summary::before { transform: rotate(90deg); }
.eval-settings-body { padding: .75rem 1rem 1rem; border-top: 1px solid var(--border); }
.eval-settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}
.eval-setting-item { display: flex; flex-direction: column; gap: .3rem; }
.eval-setting-label {
  font-size: .8rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.eval-setting-hint { font-size: .7rem; color: var(--text-muted); font-weight: 400; }
.eval-setting-ctrl { display: flex; align-items: center; gap: .5rem; }
.eval-setting-input {
  width: 90px;
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .85rem;
  background: var(--surface);
  color: var(--text);
}
.eval-setting-default { font-size: .7rem; color: var(--text-muted); }
.eval-setting-actions { display: flex; align-items: center; gap: .75rem; padding-bottom: .1rem; }
.eval-setting-reset {
  font-size: .78rem;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}
.eval-settings-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: .75rem;
  padding-top: .65rem;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.eval-setting-rerun {
  padding: .28rem .75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-size: .78rem;
  cursor: pointer;
}
.eval-setting-rerun:hover { background: #f1f5f9; }
.eval-setting-ts { font-size: .72rem; color: var(--text-muted); }

/* ── ローディングバー ── */
.eval-loading-card { padding: 1.25rem 1.5rem; }
.eval-loading-header {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .85rem;
  font-size: .9rem;
}
.eval-bar-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
}
.eval-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  border-radius: 99px;
  transition: width .5s ease;
  min-width: 4px;
}
.eval-bar-footer {
  display: flex;
  justify-content: space-between;
  margin-top: .4rem;
  font-size: .72rem;
  color: var(--text-muted);
}

/* テーブルタイトル */
.eval-table-title { font-size: .82rem; font-weight: 600; margin: .5rem 0 .4rem; }
.eval-table-title.buy  { color: #166534; }
.eval-table-title.sell { color: #991b1b; }

/* 勝敗バッジ */
.eval-hit-badge  { display:inline-block;background:#dcfce7;color:#166534;border-radius:3px;padding:.05rem .3rem;font-size:.72rem;font-weight:700; }
.eval-miss-badge { display:inline-block;background:#fee2e2;color:#991b1b;border-radius:3px;padding:.05rem .3rem;font-size:.72rem;font-weight:700; }

/* ── ポートフォリオ シグナル ── */
.pf-alert-card { padding: 0; overflow: hidden; }
.pf-alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1rem;
  background: #fef9c3;
  color: #854d0e;
  font-weight: 700;
  font-size: .88rem;
  border-bottom: 1px solid #fde68a;
}
.pf-alert-date { font-weight: 400; font-size: .72rem; color: #92400e; }

.pf-alert-row {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.pf-alert-row:last-child { border-bottom: none; }
.pf-alert-row.sell { border-left: 3px solid var(--sell); }
.pf-alert-row.buy  { border-left: 3px solid var(--buy); }

.pf-alert-main {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}
.pf-alert-code { font-weight: 700; font-size: .88rem; color: var(--text); }
.pf-alert-name { font-size: .82rem; color: var(--text-muted); flex: 1; }

.pf-alert-signals { display: flex; gap: .3rem; flex-wrap: wrap; }
.pf-alert-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: .1rem;
}
.pf-alert-pnl { font-size: .78rem; font-weight: 600; }

.pf-action-link {
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  padding: .2rem .6rem;
  border-radius: 4px;
}
.pf-action-link.sell { background: #fee2e2; color: #991b1b; }
.pf-action-link.sell:hover { background: #fecaca; }
.pf-action-link.buy  { background: #dcfce7; color: #166534; }
.pf-action-link.buy:hover  { background: #bbf7d0; }

/* シグナルスコア */
.pf-sig-score {
  display: inline-block;
  font-size: .92rem;
  font-weight: 800;
  min-width: 2.4rem;
  text-align: center;
}

/* 推奨バッジ */
.pf-rec-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 3px;
  white-space: nowrap;
}
.pf-rec-badge.strong_buy  { background: #dcfce7; color: #14532d; }
.pf-rec-badge.hold        { background: #f0fdf4; color: #166534; }
.pf-rec-badge.neutral     { background: #f8fafc; color: var(--text-muted); }
.pf-rec-badge.sell_watch  { background: #fff7ed; color: #c2410c; }
.pf-rec-badge.strong_sell { background: #fee2e2; color: #991b1b; }

/* シグナルタグ */
.pf-sig-tag {
  display: inline-block;
  font-size: .65rem;
  padding: .1rem .35rem;
  border-radius: 3px;
  background: #f1f5f9;
  color: var(--text-muted);
  white-space: nowrap;
}
.pf-sig-tag.bullish { background: #f0fdf4; color: #166534; }
.pf-sig-tag.bearish { background: #fff1f2; color: #9f1239; }

/* テーブル内シグナルセル */
.pf-sig-col { min-width: 90px; vertical-align: top; }
.pf-sig-cell { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; margin-bottom: .2rem; }
.pf-sig-keys { display: flex; flex-direction: column; gap: .15rem; }

@media (max-width: 768px) {
  .pf-sig-col { display: none; }
}

/* ── 本日の推奨シグナル ── */
.today-rec-section { margin-bottom: 1.25rem; }

.today-rec-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .65rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}
.today-rec-date {
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: .15rem .55rem;
  border-radius: 999px;
}

.today-rec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
.today-rec-card { padding: 0; overflow: hidden; }

.today-rec-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1rem;
  font-weight: 700;
  font-size: .88rem;
  border-bottom: 1px solid var(--border);
}
.today-rec-heading.buy  { background: #dcfce7; color: #166534; }
.today-rec-heading.sell { background: #fee2e2; color: #991b1b; }

.today-rec-count {
  font-size: .7rem;
  font-weight: 600;
  background: rgba(0,0,0,.08);
  padding: .1rem .45rem;
  border-radius: 999px;
}

.today-rec-signals {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.today-rec-empty {
  padding: 1.25rem 1rem;
  color: var(--text-muted);
  font-size: .82rem;
  text-align: center;
}

@media (max-width: 900px) {
  .today-rec-grid { grid-template-columns: 1fr; }
}

/* ── 管理者ナビ ── */
.nav-link-admin {
  background: #ede9fe;
  color: #7c3aed;
  border-radius: 4px;
  padding: .2rem .6rem;
  font-weight: 600;
}
.nav-link-admin:hover { background: #ddd6fe; color: #5b21b6; }

/* ── 管理画面 共通 ── */
.admin-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.admin-stat-card {
  text-align: center;
  padding: 1rem .75rem;
}
.admin-stat-val {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}
.admin-stat-lbl {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

/* ステータスバッジ */
.admin-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 3px;
  white-space: nowrap;
}
.admin-badge.admin    { background: #ede9fe; color: #7c3aed; }
.admin-badge.active   { background: #dcfce7; color: #166534; }
.admin-badge.inactive { background: #f1f5f9; color: var(--text-muted); }

/* ユーザー一覧 */
.admin-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.admin-search-input {
  padding: .35rem .75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .85rem;
  width: 260px;
  background: var(--surface);
  color: var(--text);
}
.admin-user-table td,
.admin-user-table th { padding: .55rem .75rem; }

.admin-action-btn {
  display: inline-block;
  padding: .2rem .6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .75rem;
  text-decoration: none;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
.admin-action-btn:hover { background: #f1f5f9; }

/* ユーザー詳細 */
.admin-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.admin-info-card,
.admin-action-card { padding: 1rem 1.25rem; }

.admin-info-table { width: 100%; border-collapse: collapse; }
.admin-info-table th,
.admin-info-table td { padding: .45rem .5rem; vertical-align: top; }
.admin-info-table th {
  width: 120px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  font-size: .82rem;
}
.admin-info-table tr + tr th,
.admin-info-table tr + tr td { border-top: 1px solid var(--border); }

.admin-actions { display: flex; flex-direction: column; gap: .6rem; }
.admin-op-btn {
  width: 100%;
  padding: .5rem 1rem;
  border-radius: 5px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-align: left;
}
.admin-op-btn.primary  { background: #dbeafe; color: #1d4ed8; }
.admin-op-btn.primary:hover  { background: #bfdbfe; }
.admin-op-btn.warn     { background: #fff7ed; color: #c2410c; }
.admin-op-btn.warn:hover     { background: #fed7aa; }
.admin-op-btn.ok       { background: #dcfce7; color: #166534; }
.admin-op-btn.ok:hover       { background: #bbf7d0; }
.admin-op-btn.danger   { background: #fee2e2; color: #991b1b; }
.admin-op-btn.danger:hover   { background: #fecaca; }
.admin-op-btn.disabled { background: #f1f5f9; color: var(--text-muted); cursor: not-allowed; opacity: .65; }

@media (max-width: 768px) {
  .admin-stats-row   { grid-template-columns: repeat(2, 1fr); }
  .admin-detail-grid { grid-template-columns: 1fr; }
  .admin-search-input { width: 100%; }
}
