:root {
  color-scheme: dark;
  font-family: "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background: #0b1220;
  color: #e5eef8;
  --panel: #121c2d;
  --panel-2: #17243a;
  --border: #2a3b55;
  --accent: #4ea1ff;
  --good: #4fd1a5;
  --bad: #ff758f;
  --warn: #f6c85f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #15243a, #0b1220 38%);
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  background: var(--accent);
  color: #07111f;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #2a3b55;
  color: #e5eef8;
}

button:disabled {
  opacity: .45;
  cursor: wait;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  /*
   * 下端の余白は縮小ボタンの取っ手の場所。
   * 取っ手は絶対配置なので、ここを削ると重なる。
   */
  padding: 18px 30px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 15, 27, .88);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
}

/*
 * ヘッダを縮小した状態。
 * セクション移動だけを残し、ロゴ・説明・アカウント欄を隠す。
 * 縦画面ではヘッダが画面の3割近くを占めるため、
 * 読む作業のあいだは畳めるようにする。
 */
body.is-header-collapsed .topbar-brand,
body.is-header-collapsed .auth-actions {
  display: none;
}

body.is-header-collapsed .topbar {
  padding-top: 8px;
}

/* ヘッダ下端中央の取っ手。展開時の高さを増やさない。 */
.topbar-handle {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
}

.topbar-collapse-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(23, 36, 58, .9);
  color: #cadaee;
  font-size: 13px;
  line-height: 1;
}

.topbar-collapse-button:hover {
  border-color: var(--accent);
  color: #eaf3ff;
}

.topbar-collapse-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 読み上げにだけ残す文字。 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: .02em;
}

/* ロゴとサブタイトルを横並びにする。 */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-title {
  margin: 0;
  /* 画像だけを表示するため、
     見出しテキスト由来の行間を残さない。 */
  font-size: 0;
  line-height: 0;
  flex: 0 0 auto;
}

.topbar-logo {
  display: block;
  height: 68px;
  width: auto;
  max-width: 100%;
}

/*
 * 説明文は2行までに収める。
 *
 * 以前は幅を文字数で抑えるだけだったため、狭い画面で5行に
 * なってヘッダを伸ばし、縮んだ場合は行が溢れて
 * セクション移動ボタンへ重なっていた。
 *
 * 2行はロゴの高さに収まるので、ヘッダは高くならない。
 * 3行目以降は省略記号で切る。1行に固定しないのは、
 * 全文が入らない幅で省略記号が出ると壊れて見えるため。
 */
.topbar-tagline {
  min-width: 0;
  max-width: 25ch;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 説明文を出す余地があるのは広い画面だけ。 */
@media (max-width: 1180px) {
  .topbar-tagline {
    display: none;
  }
}

.topbar p {
  margin: 0;
  color: #9db0c8;
  font-size: 13px;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#user-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ヘッダの空きスペースへ収めるセクション移動ボタン。 */
.section-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.section-nav-button {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(23, 36, 58, .75);
  color: #cadaee;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.section-nav-button:hover {
  border-color: var(--accent);
  color: #eaf3ff;
}

.section-nav-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* スクロール位置から判定した現在のセクション。 */
.section-nav-button.is-active {
  border-color: var(--accent);
  background: rgba(78, 161, 255, .18);
  color: #eaf3ff;
}

.section-nav-button--top {
  background: #2a3b55;
  color: #e5eef8;
}

main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px;
}

.panel {
  background: rgba(18, 28, 45, .95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, .18);
}

.banner {
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

#operation-status {
  color: #9db0c8;
}

.toolbar-divider {
  width: 1px;
  align-self: stretch;
  min-height: 24px;
  background: var(--border);
}

.download-status {
  color: #9db0c8;
  font-size: 13px;
}

.download-status.is-error {
  color: var(--bad);
}

/*
 * セクション移動でスクロールしたとき、
 * 固定ヘッダが見出しを覆わない高さを確保する。
 *
 * 高さは折り返しと縮小状態で変わるため、
 * `app.js` の `syncHeaderOffset()` が実測値を入れる。
 */
#investment-budget-panel,
#data-status-panel,
#jp-market-panel,
#us-market-panel,
#today-strategy-panel,
#ai-review-panel,
#portfolio-panel,
#favorites-panel,
#candidate-ranking-panel,
#input-panel {
  scroll-margin-top: var(--header-offset, 130px);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
}

.metric {
  margin-bottom: 18px;
}

.metric span {
  display: block;
  color: #9db0c8;
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
}

h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.warnings {
  margin: 0;
  color: #ffd27a;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.market-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.market-card strong {
  display: block;
  font-size: 20px;
  margin: 6px 0;
}

/* 取得失敗した系列。欠測を見落とさないよう警戒色で示す。 */
.market-card--failed {
  border-color: rgba(248, 113, 113, .55);
  background: rgba(248, 113, 113, .08);
}

.market-card--failed strong {
  color: #fca5a5;
  font-size: 16px;
}

.market-card__reason {
  color: #f3b4b4;
  font-size: 13px;
  line-height: 1.5;
}

.market-card--failed small {
  display: block;
  margin-top: 6px;
  color: #b98b8b;
  cursor: help;
}

.market-card .up {
  color: var(--good);
}

.market-card .down {
  color: var(--bad);
}

/* ---------- 日本市場セクション ---------- */

/*
 * PERと主体別売買動向の2枠。
 * `minmax()` の最小幅は `min(100%, Npx)` で包む。素の 340px だと
 * 340px未満の画面で枠が画面外へ出て、ページ全体に横スクロールが出る。
 */
.jp-market-blocks {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 12px;
  margin-top: 12px;
}

.jp-market-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.jp-market-block h3 {
  margin: 0;
  font-size: 15px;
}

.jp-market-block-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.jp-market-source {
  color: #91a5be;
  font-size: 13px;
}

.jp-market-note {
  margin: 8px 0 0;
  color: #91a5be;
  font-size: 13px;
  line-height: 1.5;
}

.jp-market-note:empty {
  display: none;
}

.jp-market-empty {
  margin: 0;
  color: #91a5be;
  font-size: 13px;
}

/*
 * 自動取得が壊れたことを枠内で示す。手入力値へ落ちた日は
 * 数値が普通に並ぶため、警戒色でないと見落とす。
 */
.jp-market-alert {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid rgba(248, 113, 113, .55);
  border-radius: 6px;
  background: rgba(248, 113, 113, .08);
  color: #f3b4b4;
  font-size: 13px;
  line-height: 1.5;
}

/* クリックで詳細を開く領域。押せることが分かる見た目にする。 */
.jp-expandable {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.jp-expandable:hover,
.jp-expandable:focus-visible {
  background: rgba(148, 163, 184, .08);
  border-color: var(--border);
}

.jp-expandable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.jp-expand-hint {
  display: block;
  margin-top: 8px;
  color: #91a5be;
  font-size: 13px;
}

.jp-per-current {
  margin-bottom: 10px;
}

.jp-per-current span {
  color: #91a5be;
  font-size: 13px;
}

.jp-per-current strong {
  display: block;
  margin: 2px 0;
  font-size: 22px;
}

.jp-per-current small {
  color: #91a5be;
  font-size: 13px;
}

/*
 * 全体の `table` は min-width: 1050px を持つ。
 * 日本市場の表は枠内へ収めるため打ち消す。
 */
.jp-per-table,
.jp-investor-table {
  min-width: 0;
  font-size: 13px;
}

/*
 * 主体別売買動向は「対象週＋4部門」の5列で、狭い画面では
 * どうしても収まらない。**枠の中で横スクロールさせる。**
 * ここを閉じないと、はみ出しがページ全体の横スクロールになる。
 */
.jp-investor-body,
.jp-per-body {
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.jp-per-table th,
.jp-per-table td,
.jp-investor-table th,
.jp-investor-table td {
  padding: 6px 8px;
}

.jp-per-table .numeric,
.jp-investor-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.jp-per-up td {
  color: var(--good);
}

.jp-per-down td {
  color: var(--bad);
}

/* 現在位置の目印。上下どちらの節目にも属さない行。 */
.jp-per-current-row td {
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  color: #e5eef8;
  font-size: 13px;
  text-align: center;
}

.jp-per-table--full .jp-per-above td {
  color: var(--good);
}

.jp-per-table--full .jp-per-below td {
  color: var(--bad);
}

.jp-investor-table th[scope="row"] {
  font-weight: 400;
  white-space: nowrap;
}

.jp-investor-table .up {
  color: var(--good);
}

.jp-investor-table .down {
  color: var(--bad);
}

/* 一部の市場区分しか無い週の目印。合計が部分値であることを示す。 */
.jp-investor-partial {
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid rgba(250, 204, 21, .5);
  border-radius: 4px;
  background: rgba(250, 204, 21, .12);
  color: #facc15;
  font-size: 13px;
  cursor: help;
}

.jp-modal-table-wrap {
  max-height: 55vh;
  overflow: auto;
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.form-modal-divider {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/*
 * チャートPNGの地色。backend/app/services/charts.py の _FIGURE_BG と同じ値。
 * 読み込み中に白がちらつかないよう、画像の地色と一致させる。
 */
.overview {
  display: block;
  width: 100%;
  max-height: 900px;
  object-fit: contain;
  border-radius: 8px;
  background: #101a2a;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  scrollbar-gutter: stable;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1050px;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #17243a;
  color: #afc3db;
  font-size: 13px;
}

td {
  font-size: 13px;
}

.badge {
  display: inline-block;
  margin: 2px;
  border: 1px solid #48617e;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 13px;
}

.candidate-grid {
  display: grid;
  /*
   * 最小幅は`min()`で包む。360pxを直に指定すると、
   * それより狭い画面でカードが画面外へ出て
   * ページ全体に横スクロールが出る。
   */
  grid-template-columns:
    repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 14px;
  margin-top: 18px;
}

.candidate-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.candidate-card img {
  width: 100%;
  background: #101a2a;
  border-radius: 6px;
  margin-top: 10px;
}

.candidate-card dl {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 5px 10px;
  font-size: 13px;
}

.candidate-card dt {
  color: #9db0c8;
}

.candidate-card dd {
  margin: 0;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

label {
  display: block;
  margin-bottom: 12px;
  color: #afc3db;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  margin-top: 5px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px;
  background: #0e1726;
  color: #e5eef8;
}

.login-message {
  max-width: 680px;
  margin: 80px auto;
  padding: 30px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.login-message p {
  margin: 0;
}

/* ログインの進行と失敗理由。空のときは行を作らない。 */
.login-status {
  color: #9fb4cd;
  font-size: 13px;
}

.login-status:not(:empty) {
  margin-top: 14px;
}

.login-status.error-message {
  color: var(--bad);
}

/* ---------- 待ち時間の膜 ---------- */

/*
 * ログイン中・読込中に画面全体を覆う。
 * ヘッダ（z-index: 5）より前へ出し、
 * 待ち時間に操作されないようにする。
 */
.app-lock {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 9, 18, 0.72);
  backdrop-filter: blur(3px);
}

.app-lock[hidden] {
  display: none;
}

.app-lock-card {
  display: flex;
  gap: 14px;
  align-items: center;
  max-width: min(100%, 420px);
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.app-lock-card p {
  margin: 0;
  font-weight: 700;
}

.app-lock-spinner {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(78, 161, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: app-lock-spin 0.9s linear infinite;
}

@keyframes app-lock-spin {
  to {
    transform: rotate(360deg);
  }
}

/* 回転を抑える設定では点滅に置き換える。 */
@media (prefers-reduced-motion: reduce) {
  .app-lock-spinner {
    animation: app-lock-pulse 1.4s ease-in-out infinite;
  }
}

@keyframes app-lock-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

@media (max-width: 900px) {

  .summary-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  /*
   * ロゴとアカウント欄を1行目、セクション移動を2行目に置く。
   * 縦並び（flex-direction: column）にすると3行になり、
   * ヘッダだけで画面の3割を使ってしまう。
   */
  .topbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 14px 22px;
  }

  .topbar-brand {
    flex: 1 1 auto;
    gap: 10px;
  }

  .topbar-logo {
    height: 38px;
  }

  .auth-actions {
    flex: 0 0 auto;
    gap: 8px;
  }

  /* 長いメールアドレスで1行目を埋めない。 */
  #user-label {
    max-width: 30vw;
    font-size: 13px;
  }

  .auth-actions button {
    padding: 6px 10px;
    font-size: 13px;
  }

  /*
   * セクション移動は折り返して全ボタンを見せる。
   *
   * 以前は1行に収めて横スクロールさせていたが、
   * 画面外のボタンに気付けず、はみ出しが不具合に見える。
   * 折り返しで増える高さは、ロゴの縮小・説明文の非表示・
   * 縮小ボタンで取り戻す。
   */
  .section-nav {
    order: 3;
    flex: 1 0 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
  }

  /* 375px幅で2行に収まる余白。文字は13pxを下回らせない。 */
  .section-nav-button {
    padding: 5px 8px;
  }
}

/* ---------- Common ---------- */

.muted {
  color: #8295ad;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin-bottom: 5px;
}

.section-note {
  margin: 0;
  color: #91a5be;
  font-size: 13px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.candidate-signs,
.candidate-warnings {
  margin-top: 8px;
}


/* ---------- Scanner badges ---------- */

.scanner-badge,
.warning-badge,
.ai-label,
.confidence-badge,
.ai-mode-label,
.ai-action-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  /*
   * 収まらない長文でも親幅で止める。
   * `flex-shrink: 0`のままだと、警告文の長いバッジが
   * 画面外へ出てページに横スクロールが出る。
   */
  max-width: 100%;
  border: 1px solid #4c76a1;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  background: #253b58;
  color: #c8e2ff;
}

/* AI判定区分ごとの色分け。強い推奨ほど暖色寄りにしない。
   撤退・見送りだけを警戒色にして誤読を防ぐ。 */
.ai-action-badge--priority {
  background: rgba(52, 211, 153, .18);
  border-color: rgba(52, 211, 153, .55);
  color: #6ee7b7;
}

.ai-action-badge--candidate {
  background: rgba(96, 165, 250, .18);
  border-color: rgba(96, 165, 250, .55);
  color: #93c5fd;
}

.ai-action-badge--watch {
  background: rgba(251, 191, 36, .18);
  border-color: rgba(251, 191, 36, .55);
  color: #fcd34d;
}

.ai-action-badge--wait {
  background: rgba(167, 139, 250, .18);
  border-color: rgba(167, 139, 250, .55);
  color: #c4b5fd;
}

.ai-action-badge--hold {
  background: rgba(56, 189, 248, .18);
  border-color: rgba(56, 189, 248, .55);
  color: #7dd3fc;
}

.ai-action-badge--avoid {
  background: rgba(248, 113, 113, .18);
  border-color: rgba(248, 113, 113, .55);
  color: #fca5a5;
}

.ai-action-badge--neutral {
  background: rgba(148, 163, 184, .16);
  border-color: rgba(148, 163, 184, .4);
  color: #cbd5e1;
}

.scanner-badge {
  flex: 0 0 auto;
  margin: 0;
  border-radius: 5px;
  white-space: nowrap;
  cursor: help;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 2px 5px rgba(0, 0, 0, 0.18);
}

/* バンド収縮：緑 */
.scanner-badge--bollinger-squeeze {
  background: #2f8d21;
  border-color: #67ca52;
  color: #f1ffed;
}

/* 55日高値ブレイク：オレンジ */
.scanner-badge--breakout {
  background: #b56016;
  border-color: #e49745;
  color: #fff5e8;
}

/* 上昇押し目：青 */
.scanner-badge--trend-pullback {
  background: #275ca8;
  border-color: #5b91df;
  color: #eff6ff;
}

/* 反転上昇：マゼンタ */
.scanner-badge--reversal {
  background: #a32182;
  border-color: #dd59ba;
  color: #fff0fb;
}

/* 業種内優位：水色 */
.scanner-badge--sector-relative {
  background: #0795c5;
  border-color: #40c7ed;
  color: #effcff;
}

/* 需給改善：青緑 */
.scanner-badge--supply-demand {
  background: #087c70;
  border-color: #3bc2b2;
  color: #edfffc;
}

/* 踏み上げ候補：赤 */
.scanner-badge--short-squeeze {
  background: #ae3546;
  border-color: #e26a79;
  color: #fff1f3;
}

.scanner-badge--unknown {
  background: #3d4b5f;
  border-color: #71839b;
  color: #f0f4f8;
}

.warning-badge {
  background: #493516;
  border-color: #a97925;
  color: #ffd889;
  /*
   * 警告はラベルではなく文章。狭い画面では折り返す。
   * `nowrap`のままだと`max-width`で止めても文字が
   * バッジの外へ出てしまう。
   */
  white-space: normal;
}


/* ---------- Candidate charts ---------- */

.chart-slot {
  margin-top: 12px;
}

.chart-thumbnail {
  display: block;
  width: 100%;
  background: #101a2a;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: zoom-in;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}

.chart-thumbnail:hover,
.chart-thumbnail:focus {
  border-color: #77b7ff;
  transform: translateY(-2px);
  outline: none;
}

.chart-thumbnail.is-loading {
  min-height: 220px;
  opacity: 0.45;
  cursor: wait;
}

.chart-empty {
  margin: 12px 0 0;
  padding: 14px;
  border: 1px dashed #40536d;
  border-radius: 7px;
  color: #91a5be;
  text-align: center;
  font-size: 13px;
}


/* ---------- Supply and demand breakdown ---------- */

/*
 * 需給の根拠。既定では畳んでおく。
 * カードの高さを押し上げると候補一覧の一覧性が落ちるため、
 * 開いたときだけ内訳を見せる。
 */
.supply-demand {
  margin-top: 13px;
  padding: 10px 12px;
  border: 1px solid #354b68;
  border-radius: 9px;
  background: rgba(10, 21, 36, 0.65);
  font-size: 13px;
}

.supply-demand > summary {
  cursor: pointer;
  color: #c5e3ff;
  font-weight: 600;
}

.supply-demand__count {
  margin-left: 7px;
  color: #91a5be;
  font-weight: 400;
}

.supply-demand__rows {
  margin-top: 11px;
  display: grid;
  gap: 8px;
}

.supply-demand__row {
  display: grid;
  grid-template-columns: minmax(min(100%, 92px), auto) 1fr;
  gap: 3px 10px;
  align-items: baseline;
}

.supply-demand__label {
  color: #91a5be;
}

.supply-demand__value {
  color: #d9e6f3;
}

/*
 * 出典と基準日の注記。数値だけを見て売り残高の全体と
 * 読み違えるのを防ぐため、必ず値の直下へ出す。
 */
.supply-demand__note {
  grid-column: 2;
  color: #7f93ab;
  font-size: 13px;
}

.supply-demand__signals {
  margin-top: 11px;
}

.supply-demand__signal {
  display: inline-block;
  margin: 2px;
  padding: 2px 8px;
  border: 1px solid #40536d;
  border-radius: 999px;
  color: #b6c8dd;
  font-size: 13px;
}


/* ---------- Candidate AI review ---------- */

.candidate-ai-review {
  margin-top: 15px;
  padding: 13px;
  border: 1px solid #354b68;
  border-radius: 9px;
  background: rgba(10, 21, 36, 0.65);
}

.candidate-ai-review__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.ai-summary {
  margin: 11px 0;
  color: #d9e6f3;
  line-height: 1.7;
  font-size: 13px;
}

.ai-label--strong {
  background: #153b2c;
  border-color: #359d75;
  color: #bdf4dd;
}

.ai-label--candidate {
  background: #163455;
  border-color: #438bd0;
  color: #c5e3ff;
}

.ai-label--watch {
  background: #413716;
  border-color: #b9952e;
  color: #ffe19a;
}

.ai-label--avoid {
  background: #4a2028;
  border-color: #b65667;
  color: #ffd1d9;
}

.ai-label--unknown {
  background: #293549;
  border-color: #52657e;
  color: #d5dfeb;
}

.confidence-badge {
  background: #26354a;
  border-color: #51647e;
  color: #cdd9e6;
}

.ai-score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.ai-score-grid span {
  padding: 7px 9px;
  border-radius: 6px;
  background: #132035;
  color: #9eb2ca;
  font-size: 13px;
}

.ai-score-grid strong {
  margin-left: 4px;
  color: #f2f7fc;
}

.ai-details {
  margin-top: 8px;
}

.ai-details summary {
  color: #8fc2ff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.ai-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 11px;
}

.ai-list-block {
  padding: 10px;
  border-left: 3px solid #51647e;
  border-radius: 5px;
  background: #111d2f;
}

.ai-list-block h4 {
  margin: 0 0 6px;
  color: #c9d8e8;
  font-size: 13px;
}

.ai-list-block ul {
  margin: 0;
  padding-left: 18px;
  color: #b6c6d8;
  font-size: 13px;
  line-height: 1.6;
}

.ai-list-block.is-positive {
  border-left-color: #45b78a;
}

.ai-list-block.is-negative {
  border-left-color: #d86279;
}

.ai-list-block.is-warning {
  border-left-color: #d6a944;
}

.ai-list-block.is-muted {
  border-left-color: #6e8199;
}

/*
 * データ上の注意。判断材料ではなく前提条件のため、
 * リスクや競合より一段弱める。文字サイズは13pxが下限のため、
 * 縮小ではなく色と枠の強さで差を付ける。
 */
.ai-list-block.is-note {
  border-left-width: 2px;
  border-left-color: #44566d;
  background: #0e1927;
}

.ai-list-block.is-note h4 {
  color: #94a8c0;
}

.ai-list-block.is-note ul {
  color: #8ea2b8;
}


/* ---------- Final AI review ---------- */

.ai-mode-label {
  flex-shrink: 0;
  background: #223853;
  border-color: #4c76a1;
  color: #c8e2ff;
}

.ai-review-notice {
  padding: 14px;
  border: 1px solid #31587a;
  border-radius: 8px;
  background: #142a3d;
  color: #bfdef6;
}

.ai-review-notice.is-warning {
  border-color: #826025;
  background: #3a2d17;
  color: #ffe0a0;
}

.ai-review-summary {
  display: grid;
  /* 市場判断は語句が短いため、内容幅に収める。 */
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 16px;
  border: 1px solid #365273;
  border-radius: 10px;
  background: #111f32;
}

.ai-review-summary>div,
.ai-review-columns>section {
  min-width: 0;
}

.ai-review-summary p {
  margin: 7px 0 0;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.eyebrow {
  color: #8fc2ff;
  font-size: 13px;
  font-weight: 700;
}

.ai-regime-box {
  /* 幅はラベルの nowrap が下限を決めるため指定しない。
     min-width を書いても .ai-review-summary>div に負ける。 */
  padding: 10px 14px;
  border-radius: 8px;
  background: #182b43;
  text-align: left;
}

.ai-regime-box span {
  display: block;
  color: #91a5be;
  font-size: 13px;
  white-space: nowrap;
}

.ai-regime-box strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ai-review-disclaimer {
  margin: 9px 0 16px;
  color: #94a8c0;
  font-size: 13px;
}

.ai-review-columns {
  display: grid;
  /* 最小幅は min() で包む。220px を下回る画面でカードが
     画面外へ出てページ全体に横スクロールが出るのを防ぐ。 */
  grid-template-columns: minmax(min(100%, 220px), 0.65fr) minmax(0, 1.35fr);
  gap: 16px;
}

/* リスクと競合は隣接すると詰まって見えるため間隔を空ける。
   優先順位より縦が長くなるので上寄せにする。 */
.ai-review-blocks {
  display: grid;
  gap: 12px;
  align-content: start;
}

.ai-review-notes {
  margin-top: 16px;
}

/*
 * 1段組で全幅を使う。2段に割ると1項目あたりの幅が半分になり、
 * ほとんどの項目が2行へ折り返してかえって読みにくかった。
 *
 * ここだけ12pxを使う。最小13pxの例外（付録E.5）。
 * 判断材料ではなく前提条件の列挙であり、1項目を1行へ収めることを
 * 優先する。
 */
.ai-review-notes ul {
  font-size: 12px;
}

.ai-review-notes li {
  margin-bottom: 5px;
}

.ai-review-columns h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.ai-ranked-list {
  margin: 0;
  padding-left: 28px;
  line-height: 1.9;
}

.ai-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 12px;
  margin-top: 17px;
}

/*
 * 幅が十分あるときは3列に固定する。
 * auto-fillのままだと4列＋1枚の折り返しになり、
 * 最終行に大きな余白が生まれる。
 */
@media (min-width: 1060px) {
  .ai-plan-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.ai-plan-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid #354b68;
  border-radius: 9px;
  background: #111d2f;
  /* 判定区分をカード左端の色帯でも示し、
     一覧を流し読みしたときに識別できるようにする。 */
  border-left-width: 3px;
}

.ai-plan-card--priority {
  border-left-color: #34d399;
}

.ai-plan-card--candidate {
  border-left-color: #60a5fa;
}

.ai-plan-card--watch {
  border-left-color: #fbbf24;
}

.ai-plan-card--wait {
  border-left-color: #a78bfa;
}

.ai-plan-card--hold {
  border-left-color: #38bdf8;
}

.ai-plan-card--avoid {
  border-left-color: #f87171;
}

.ai-plan-card--neutral {
  border-left-color: #64748b;
}

.ai-plan-card__title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.ai-plan-card h3 {
  margin: 0;
  font-size: 14px;
}

.ai-plan-card p {
  color: #c5d3e2;
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.ai-plan-card dl {
  display: grid;
  grid-template-columns: 105px minmax(0, 1fr);
  gap: 5px 8px;
  font-size: 13px;
}

.ai-plan-card dt {
  color: #91a5be;
}

.ai-plan-card dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---------- Chart modal ---------- */

body.modal-open {
  overflow: hidden;
}

.chart-modal {
  width: min(96vw, 1680px);
  max-width: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #e5eef8;
}

.chart-modal::backdrop {
  background: rgba(2, 7, 14, 0.86);
  backdrop-filter: blur(4px);
}

.chart-modal-shell {
  display: flex;
  flex-direction: column;
  max-height: 94vh;
  overflow: hidden;
  border: 1px solid #40536d;
  border-radius: 12px;
  background: #101a2a;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.65);
}

.chart-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 13px 16px;
  border-bottom: 1px solid #344860;
}

.chart-modal-header h2 {
  margin: 0 0 4px;
}

.chart-modal-header p {
  margin: 0;
  color: #91a5be;
  font-size: 13px;
}

.chart-modal-close {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: #2a3b55;
  color: #edf5ff;
  font-size: 27px;
  line-height: 1;
}

.chart-modal-close:hover {
  background: #405675;
}

.chart-modal-body {
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 12px;
  background: #08101c;
}

.chart-modal-image {
  display: block;
  max-width: 100%;
  max-height: calc(94vh - 90px);
  object-fit: contain;
  background: #101a2a;
}

/* ---------- Responsive ---------- */

@media (max-width: 800px) {

  .section-heading,
  .candidate-ai-review__header,
  .ai-plan-card__title {
    flex-direction: column;
  }

  .ai-review-summary,
  .ai-review-columns,
  .ai-details-grid {
    grid-template-columns: 1fr;
  }

  .ai-regime-box {
    width: 100%;
  }

  .chart-modal {
    width: 98vw;
  }

  .chart-modal-shell {
    max-height: 97vh;
  }

  .chart-modal-image {
    max-height: calc(97vh - 90px);
  }
}

/* ========================================
   候補ランキング表
======================================== */

.candidate-ranking-table {
  width: 100%;
  /*
   * 13px の文字が12列に収まる下限。
   * これを下回ると見出しが折り返すため、
   * 圧縮せず .table-wrap 側で横スクロールさせる。
   */
  min-width: 1180px;
  table-layout: fixed;
  border-collapse: collapse;
}

.candidate-ranking-table th,
.candidate-ranking-table td {
  box-sizing: border-box;
  padding: 9px 8px;
  vertical-align: middle;
  line-height: 1.25;
}

.candidate-ranking-table tbody tr {
  height: 62px;
}

.candidate-ranking-table tbody td {
  border-bottom: 1px solid #30435d;
}

/* 合計100% */
.candidate-ranking-table .col-rank {
  /* 13px の「順位」が折り返さない幅。 */
  width: 4.5%;
}

.candidate-ranking-table .col-code {
  width: 5%;
}

.candidate-ranking-table .col-company {
  width: 13%;
}

.candidate-ranking-table .col-sector {
  width: 9%;
}

.candidate-ranking-table .col-current {
  width: 7%;
}

.candidate-ranking-table .col-score {
  /* 13px の「スコア」が折り返さない幅。 */
  width: 6.5%;
}

.candidate-ranking-table .col-adjustment {
  /* 13px の「朝調整」が折り返さない幅。 */
  width: 6.5%;
}

.candidate-ranking-table .col-signals {
  width: 16%;
}

.candidate-ranking-table .col-entry {
  width: 12%;
}

.candidate-ranking-table .col-target {
  width: 6.5%;
}

.candidate-ranking-table .col-stop {
  width: 7.5%;
}

.rank-cell,
.code-cell,
.score-cell,
.adjustment-cell,
.plan-price-cell {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.rank-cell,
.numeric-heading,
.score-cell,
.adjustment-cell,
.price-heading {
  text-align: center;
}

.code-cell,
.score-cell,
.adjustment-cell,
.plan-price-cell,
.price-heading {
  white-space: nowrap;
}

.company-cell,
.sector-cell {
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-cell {
  color: #f1f6fc;
  font-weight: 700;
}

.adjustment-cell {
  color: #b7c7d9;
}

.signals-cell {
  overflow: hidden;
}

.signal-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.signal-list .scanner-badge {
  padding: 4px 9px;
  font-size: 13px;
  line-height: 1.2;
}

.signal-empty,
.price-plan-empty {
  color: #7f91a8;
  font-size: 13px;
}

.plan-price-cell {
  padding-right: 3px;
  padding-left: 3px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
}

.entry-price-cell {
  color: #75bcff;
}

.target-price-cell {
  color: #72e3b2;
}

.stop-price-cell {
  color: #ff8296;
}

.stop-heading {
  color: #ff9cac;
}

.entry-range {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) 15px minmax(70px, 1fr);
  align-items: center;
  width: 100%;
  gap: 2px;
}

.entry-range span:first-child,
.entry-range span:last-child {
  text-align: right;
}

.entry-range__separator {
  text-align: center;
  color: #8295ad;
  font-weight: 400;
}

/* renderPricePlan()を再利用する場合のカード型価格表示 */
.price-plan-cell {
  padding-top: 8px;
  padding-bottom: 8px;
}

.price-plan {
  display: grid;
  gap: 4px;
  min-width: 270px;
  padding: 8px 10px;
  border: 1px solid #344a67;
  border-radius: 7px;
  background: rgba(8, 18, 32, 0.55);
}

.price-plan__row {
  display: grid;
  grid-template-columns: 70px minmax(76px, 1fr) 17px minmax(76px, 1fr);
  align-items: baseline;
  gap: 3px;
  min-height: 22px;
}

.price-plan__label {
  grid-column: 1;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.price-plan__number {
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.price-plan__number--single {
  grid-column: 2 / 5;
}

.price-plan__separator {
  text-align: center;
  color: #8395ac;
}

.price-plan__row--entry .price-plan__label,
.price-plan__row--entry .price-plan__number {
  color: #8bc7ff;
}

.price-plan__row--target .price-plan__label,
.price-plan__row--target .price-plan__number {
  color: #8ee5bd;
}

.price-plan__row--stop .price-plan__label,
.price-plan__row--stop .price-plan__number {
  color: #ff9dad;
}

.price-plan__row--stop {
  margin-top: 2px;
  padding-top: 5px;
  border-top: 1px solid #344a67;
}


/* ========================================
   保有ポートフォリオ
======================================== */

.portfolio-panel-status {
  color: #91a5be;
  font-size: 13px;
  white-space: nowrap;
}

.portfolio-empty {
  padding: 22px;
  border: 1px dashed #40536d;
  border-radius: 8px;
  color: #91a5be;
  text-align: center;
}

.portfolio-summary-grid {
  display: grid;
  grid-template-columns:
    repeat(5, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.portfolio-summary-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid #304761;
  border-radius: 8px;
  background: #142137;
}

.portfolio-summary-card span {
  display: block;
  color: #91a5be;
  font-size: 13px;
}

.portfolio-summary-card strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: #edf5ff;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-summary-card small {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.portfolio-warning-list {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.portfolio-warning {
  padding: 8px 10px;
  border: 1px solid #80612a;
  border-radius: 6px;
  background: #3a2c14;
  color: #ffe0a0;
  font-size: 13px;
}

.portfolio-data-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 10px;
  color: #91a5be;
  font-size: 13px;
}

.portfolio-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.portfolio-table {
  width: 100%;
  min-width: 1180px;
  table-layout: fixed;
  border-collapse: collapse;
}

.portfolio-col-security {
  width: 13%;
}

.portfolio-col-account {
  width: 10%;
}

.portfolio-col-quantity {
  width: 6%;
}

.portfolio-col-price {
  width: 8%;
}

.portfolio-col-value {
  width: 9%;
}

.portfolio-col-profit {
  width: 9%;
}

.portfolio-col-sector {
  width: 8%;
}

.portfolio-col-score {
  width: 7%;
}

.portfolio-col-tactic {
  width: 22%;
}

.portfolio-table th,
.portfolio-table td {
  padding: 9px 7px;
  vertical-align: middle;
}

.portfolio-table th {
  text-align: left;
  white-space: nowrap;
}

.portfolio-security-cell strong,
.portfolio-security-cell span {
  display: block;
}

.portfolio-security-cell span {
  margin-top: 3px;
  overflow: hidden;
  color: #b9c9da;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-account-cell,
.portfolio-sector-cell {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
}

.portfolio-number-cell,
.portfolio-score-cell {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.portfolio-number-cell small,
.portfolio-score-cell small {
  display: block;
  margin-top: 3px;
  color: #8397af;
  font-size: 13px;
  white-space: normal;
}

.portfolio-score-cell strong {
  color: #8fc2ff;
}

.portfolio-profit--positive {
  color: #72e3b2 !important;
}

.portfolio-profit--negative {
  color: #ff8296 !important;
}

.portfolio-profit--neutral {
  color: #c3d0de !important;
}

.portfolio-tactic-cell>div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.portfolio-tactic-cell small {
  display: block;
  margin-top: 5px;
  color: #9eb0c5;
  font-size: 13px;
  line-height: 1.45;
}

.portfolio-tactic-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.portfolio-tactic-badge--danger {
  border-color: #d76576;
  background: #7c2635;
  color: #ffe7eb;
}

.portfolio-tactic-badge--profit {
  border-color: #43b98b;
  background: #176044;
  color: #e3fff4;
}

.portfolio-tactic-badge--add {
  border-color: #4f94dc;
  background: #1f5489;
  color: #e8f4ff;
}

.portfolio-tactic-badge--neutral {
  border-color: #62758d;
  background: #34445a;
  color: #e3eaf2;
}

/* ---------- お気に入り ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.favorites-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#favorites-status {
  color: #9db0c8;
  font-size: 13px;
  white-space: nowrap;
}

.favorites-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
}

.favorites-search input {
  flex: 1 1 320px;
  min-width: 0;
}

.favorites-search button {
  flex: 0 0 auto;
}

.favorites-message {
  margin: 10px 0 0;
  color: #9fd8b4;
  font-size: 13px;
}

.favorites-message.is-error {
  color: #fca5a5;
}

.favorites-search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 8px;
  /* 検索結果が表のヘッダーに接しないよう下側も空ける。 */
  margin: 12px 0 20px;
}

.favorites-match {
  display: block;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.favorites-match:hover:not(:disabled) {
  border-color: #4c76a1;
}

.favorites-match:disabled {
  opacity: .55;
  cursor: default;
}

.favorites-match strong {
  font-variant-numeric: tabular-nums;
}

.favorites-match span {
  display: block;
  font-size: 13px;
}

.favorites-match small {
  display: block;
  color: #8497ae;
  font-size: 13px;
}

/* 候補ランキングの列定義を流用し、順位と朝調整の分を配分する。 */
.favorites-table .col-code {
  width: 6%;
}

.favorites-table .col-company {
  width: 16%;
}

.favorites-table .col-score {
  /* 「スコア」の見出しが折り返さない幅を確保する。 */
  width: 7%;
}

.favorites-table .col-signals {
  width: 17%;
}

.favorites-table .col-actions {
  width: 7%;
}

.favorites-action-cell {
  vertical-align: middle;
  text-align: center;
}

.favorites-remove {
  padding: 3px 10px;
  border: 1px solid rgba(248, 113, 113, .45);
  border-radius: 999px;
  background: rgba(248, 113, 113, .14);
  color: #fca5a5;
  font-size: 13px;
  cursor: pointer;
}

.favorites-remove:hover {
  background: rgba(248, 113, 113, .24);
}

/* ファイル選択欄と実行ボタンが密着しないようにする。 */
.upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.upload-row input[type="file"] {
  flex: 1 1 260px;
  min-width: 0;
}

.upload-row button {
  flex: 0 0 auto;
}

/* ---------- Panel forms ---------- */

/* 入力欄の意味を1箇所で説明する注記。 */
.panel-note {
  margin: 0 0 14px;
  color: #94a8c0;
  font-size: 13px;
  line-height: 1.7;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

/*
 * 保存や削除の結果を出す行。
 * 押しても画面が変わらないと、押せていないように見える（付録G）。
 * 処理中・成功・失敗を必ずここへ出す。
 */
.form-status {
  margin: 10px 0 0;
  min-height: 1.2em;
  color: #c9d8e8;
  font-size: 13px;
  line-height: 1.6;
}

.form-status.is-busy {
  color: #8fc2ff;
}

.form-status.is-success {
  color: #7fd7ac;
}

.form-status.is-error {
  color: #f2909f;
}

.form-status.is-muted {
  color: #8ea2b8;
}

.position-evaluation-section {
  margin-top: 26px;
}

.position-evaluation-section h3 {
  margin: 0;
  font-size: 15px;
}

.position-evaluation-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#position-evaluation-status {
  color: #9db0c8;
  font-size: 13px;
  white-space: nowrap;
}

/* 候補ランキングと同じ列定義を使いつつ、
   順位と朝調整の列がない分を配分する。 */
.position-evaluation-table .col-code {
  width: 6%;
}

.position-evaluation-table .col-company {
  width: 15%;
}

.position-evaluation-table .col-score {
  /* 「スコア」の見出しが折り返さない幅を確保する。 */
  width: 7%;
}

.position-evaluation-table .col-signals {
  width: 16%;
}

.position-evaluation-table .col-entry {
  width: 8%;
}

.position-evaluation-table .col-plan-state {
  width: 11%;
}

.position-evaluation-table .col-tactic {
  width: 13%;
}

.plan-state-cell {
  vertical-align: middle;
}

.plan-state-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
}

.plan-state-badge--initial {
  background: rgba(120, 144, 176, .16);
  border-color: rgba(120, 144, 176, .4);
  color: #b6c6da;
}

.plan-state-badge--revised {
  background: rgba(96, 165, 250, .16);
  border-color: rgba(96, 165, 250, .45);
  color: #93c5fd;
}

.plan-state-badge--trailed {
  background: rgba(52, 211, 153, .16);
  border-color: rgba(52, 211, 153, .45);
  color: #6ee7b7;
}

.plan-state-badge--pending {
  background: rgba(251, 191, 36, .16);
  border-color: rgba(251, 191, 36, .45);
  color: #fcd34d;
}

.plan-state-badge--missing {
  background: rgba(148, 163, 184, .12);
  border-color: rgba(148, 163, 184, .32);
  color: #94a3b8;
}

.position-evaluation-table .current-price-cell small {
  display: block;
  color: #8497ae;
  font-size: 13px;
}

.portfolio-sector-section {
  margin-top: 16px;
}

.portfolio-sector-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.portfolio-sector-list {
  display: grid;
  grid-template-columns:
    repeat(auto-fit,
      minmax(220px, 1fr));
  gap: 10px;
}

.portfolio-sector-row {
  padding: 10px;
  border: 1px solid #304761;
  border-radius: 7px;
  background: #111d2f;
}

.portfolio-sector-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.portfolio-sector-track {
  height: 6px;
  margin: 7px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #25364d;
}

.portfolio-sector-bar {
  height: 100%;
  border-radius: inherit;
  background: #4ea1ff;
}

.portfolio-sector-row small {
  color: #91a5be;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .portfolio-summary-grid {
    grid-template-columns:
      repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 650px) {
  .portfolio-summary-grid {
    grid-template-columns: 1fr;
  }

  .portfolio-panel-status {
    white-space: normal;
  }
}

/* 保有ポートフォリオ表のヘッダー */
.portfolio-table thead th {
  text-align: center;
  vertical-align: middle;
}

/* ---------- Analysis status banner ---------- */

.banner.analysis {
  border: 1px solid #31587a;
  background: #142a3d;
  color: #bfdef6;
}

.banner.analysis--complete {
  border-color: #2b7a64;
  background: #15382e;
  color: #bff8e2;
}

.banner.analysis--partial {
  border-color: #80612a;
  background: #3a2c14;
  color: #ffe4a0;
}

.banner.analysis--failed {
  border-color: #b65667;
  background: #4a2028;
  color: #ffd1d9;
}

/* ---------- Candidate current price ---------- */

.current-price-cell {
  color: #f1f6fc;
  text-align: right;
  white-space: nowrap;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
/* ========================================
   投資予算
======================================== */

.investment-budget-panel {
  margin-top: 0;
}

.investment-budget-grid {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(190px, 1fr));
  gap: 12px;
}

.investment-budget-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid #304761;
  border-radius: 9px;
  background: #142137;
}

.investment-budget-card span {
  display: block;
  color: #91a5be;
  font-size: 13px;
}

.investment-budget-card strong {
  display: block;
  margin-top: 7px;
  color: #edf5ff;
  font-size: 23px;
  line-height: 1.3;
}

.investment-budget-card small {
  display: block;
  margin-top: 5px;
  color: #91a5be;
  font-size: 13px;
  line-height: 1.5;
}

.investment-budget-status {
  margin: 12px 0 0;
  color: #9db0c8;
  font-size: 13px;
}


/* ========================================
   今日の戦術
======================================== */

.today-strategy-panel {
  border-color: #355f89;
}

.today-strategy-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.today-strategy-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid #40536d;
  border-radius: 999px;
  background: #17243a;
  color: #b8c8db;
  font-size: 13px;
  font-weight: 700;
}

.today-strategy-status.is-current {
  border-color: #2b7a64;
  background: #15382e;
  color: #bff8e2;
}

.today-strategy-status.is-expired {
  border-color: #80612a;
  background: #3a2c14;
  color: #ffe4a0;
}

.today-strategy-status.is-failed {
  border-color: #91384c;
  background: #3b1822;
  color: #ffc5d0;
}

.today-strategy-empty {
  padding: 24px;
  border: 1px dashed #40536d;
  border-radius: 9px;
  color: #91a5be;
  text-align: center;
}

.today-strategy-content {
  display: grid;
  gap: 14px;
}

.today-strategy-section {
  padding: 15px;
  border: 1px solid #304761;
  border-radius: 9px;
  background: #142137;
}

.today-strategy-section h3 {
  margin: 0 0 8px;
  color: #edf5ff;
  font-size: 16px;
}

.today-strategy-section p {
  margin: 0;
  line-height: 1.75;
}

.today-strategy-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 20px;
}

.today-strategy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: #91a5be;
  font-size: 13px;
}


/* ========================================
   入力モーダル
======================================== */

.form-modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #40536d;
  border-radius: 12px;
  background: #121c2d;
  color: #e5eef8;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .55);
}

.form-modal::backdrop {
  background: rgba(2, 8, 18, .78);
  backdrop-filter: blur(4px);
}

.form-modal-shell {
  display: flex;
  max-height: calc(100vh - 48px);
  flex-direction: column;
}

.form-modal-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #2a3b55;
}

.form-modal-header h2 {
  margin: 0;
  font-size: 19px;
}

.form-modal-header p {
  margin: 6px 0 0;
  color: #9db0c8;
  font-size: 13px;
  line-height: 1.6;
}

.form-modal-close {
  min-width: 38px;
  padding: 6px 10px;
  background: transparent;
  color: #d7e4f2;
  font-size: 22px;
  line-height: 1;
}

.form-modal-close:hover {
  background: #263750;
}

.form-modal-body {
  padding: 20px;
  overflow-y: auto;
}

.form-modal-body label {
  display: block;
  margin-bottom: 8px;
  color: #d7e4f2;
  font-size: 13px;
  font-weight: 700;
}

.currency-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.currency-input input {
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid #40536d;
  border-radius: 8px;
  outline: none;
  background: #0f1929;
  color: #edf5ff;
  font-size: 18px;
}

.currency-input input:focus {
  border-color: #4ea1ff;
  box-shadow: 0 0 0 3px rgba(78, 161, 255, .16);
}

.currency-input span {
  color: #c6d5e6;
  font-weight: 700;
}

.form-help {
  margin: 10px 0 0;
  color: #91a5be;
  font-size: 13px;
  line-height: 1.6;
}

.form-modal-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: #ffb6c4;
  font-size: 13px;
}

.form-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 15px 20px;
  border-top: 1px solid #2a3b55;
}


@media (max-width: 760px) {
  .investment-budget-grid {
    grid-template-columns: 1fr;
  }

  .today-strategy-heading-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .form-modal-actions {
    flex-direction: column-reverse;
  }

  .form-modal-actions button {
    width: 100%;
  }
}

/* ========================================
   今日の戦術・詳細レポート
======================================== */

.today-strategy-meta strong {
  margin-left: 4px;
  color: #dce9f7;
}

.today-strategy-executive {
  border-color: #3c79b1;
  background: #142b45;
}

.today-strategy-standard {
  border-color: #337c6a;
  background: #14352f;
}

.today-strategy-focus-grid {
  display: grid;
  gap: 12px;
}

.today-strategy-focus-card {
  padding: 15px;
  border: 1px solid #304761;
  border-radius: 9px;
  background: #0f1a2a;
}

.today-strategy-focus-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.today-strategy-focus-header h4 {
  margin: 5px 0 0;
  color: #edf5ff;
  font-size: 17px;
}

.today-strategy-focus-category {
  color: #91a5be;
  font-size: 13px;
}

.today-strategy-action-badge {
  display: inline-flex;
  max-width: 100%;
  min-height: 28px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid #397bb5;
  border-radius: 999px;
  background: #15314d;
  color: #c8e6ff;
  font-size: 13px;
  font-weight: 700;
}

.today-strategy-focus-card h5 {
  margin: 0 0 8px;
  color: #dce9f7;
  font-size: 14px;
}

.today-strategy-focus-card > p {
  margin: 0;
  line-height: 1.75;
}

.today-strategy-focus-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 13px;
  padding: 9px 11px;
  border-radius: 7px;
  background: #17263b;
}

.today-strategy-focus-row span {
  color: #91a5be;
  font-size: 13px;
}

.today-strategy-focus-row strong {
  color: #edf5ff;
  font-size: 13px;
}

.today-strategy-focus-note {
  margin: 8px 0 0;
  color: #b7c8db;
  font-size: 13px;
  line-height: 1.65;
}

.today-strategy-subsection {
  margin-top: 12px;
  padding: 11px;
  background: #142137;
}

.today-strategy-subsection h3 {
  font-size: 13px;
}

.today-strategy-subsection .today-strategy-list {
  font-size: 13px;
}

.today-strategy-behavior-warning {
  margin-top: 12px;
  padding: 11px;
  border: 1px solid #80612a;
  border-radius: 7px;
  background: #3a2c14;
  color: #ffe0a0;
}

.today-strategy-behavior-warning strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.today-strategy-behavior-warning p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
}

.today-strategy-aggressive {
  border-color: #40536d;
}

.today-strategy-aggressive.is-recommended {
  border-color: #9b7027;
  background: #34280f;
}

.today-strategy-aggressive-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.today-strategy-aggressive-header h3 {
  margin: 0;
}

.today-strategy-aggressive-header span {
  padding: 4px 9px;
  border: 1px solid #526680;
  border-radius: 999px;
  color: #c5d3e2;
  font-size: 13px;
  font-weight: 700;
}

.today-strategy-aggressive.is-recommended
.today-strategy-aggressive-header span {
  border-color: #a87927;
  color: #ffe0a0;
}

.today-strategy-budget-line {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 13px;
}

.today-strategy-budget-line span {
  padding: 10px;
  border-radius: 7px;
  background: rgba(8, 18, 31, .55);
  color: #91a5be;
  font-size: 13px;
}

.today-strategy-budget-line strong {
  display: block;
  margin-top: 5px;
  color: #edf5ff;
  font-size: 15px;
}

.today-strategy-user-context {
  border-color: #6b5c96;
  background: #241f3a;
}

.today-strategy-guardrails {
  border-color: #80612a;
}

.today-strategy-data-warnings {
  border-color: #6c5660;
  background: #261c23;
}


@media (max-width: 760px) {
  .today-strategy-budget-line {
    grid-template-columns: 1fr;
  }

  .today-strategy-focus-header {
    flex-direction: column;
  }
}
today_strategy_css_append_exit=0cat

/* ========================================
   今日の戦術・再生成入力
======================================== */

.today-strategy-context-input {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  padding: 12px;
  border: 1px solid #40536d;
  border-radius: 8px;
  outline: none;
  background: #0f1929;
  color: #edf5ff;
  line-height: 1.7;
}

.today-strategy-context-input:focus {
  border-color: #4ea1ff;
  box-shadow: 0 0 0 3px rgba(78, 161, 255, .16);
}

.today-strategy-context-input::placeholder {
  color: #6f849d;
}

.today-strategy-context-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  margin-top: 8px;
  color: #91a5be;
  font-size: 13px;
  line-height: 1.5;
}

.today-strategy-context-examples {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #304761;
  border-radius: 8px;
  background: #142137;
}

.today-strategy-context-examples strong {
  display: block;
  margin-bottom: 7px;
  color: #dce9f7;
  font-size: 13px;
}

.today-strategy-context-examples ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 20px;
  color: #aebfd2;
  font-size: 13px;
  line-height: 1.55;
}

