/* ==========================================================================
   style.css
   基本レイアウトの微調整とカスタムコンポーネントスタイル
   ========================================================================== */

html, body { scroll-behavior: smooth; }

.axis-select {
  width: 100%;
  font-size: 0.8rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  background-color: #fff;
  color: #1e293b;
  outline: none;
  transition: border-color .15s ease;
}
.axis-select:focus {
  border-color: #3d6bf0;
  box-shadow: 0 0 0 2px rgba(61,107,240,0.15);
}

/* 軸に指標を選んだ直後に現れる、種別（実績／会社予想）と決算期の指定欄。
   指標によって出る項目が変わるため、中身はJS側で組み立てる。 */
.axis-sub {
  margin-top: 0.4rem;
  padding-left: 0.55rem;
  border-left: 2px solid #dbe7ff;
}
.axis-sub:empty { display: none; }
.axis-sub-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.3rem;
}
.axis-sub-label {
  flex: 0 0 2.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: #94a3b8;
}
.axis-subselect {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.7rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  background-color: #fff;
  color: #334155;
  outline: none;
}
.axis-subselect:focus {
  border-color: #3d6bf0;
  box-shadow: 0 0 0 2px rgba(61,107,240,0.15);
}
.axis-sub-arrow {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: #94a3b8;
}
.axis-sub-hint {
  margin-top: 0.3rem;
  font-size: 0.63rem;
  line-height: 1.45;
  color: #94a3b8;
}


/* モーダル表示制御用 (flex/hiddenの切り替えはJSで.hidden付け外し) */
.modal-open { display: flex !important; }

/* スクロールバー */
#top-companies-list::-webkit-scrollbar,
#sector-filter-list::-webkit-scrollbar,
#report-body::-webkit-scrollbar {
  width: 6px;
}
#top-companies-list::-webkit-scrollbar-thumb,
#sector-filter-list::-webkit-scrollbar-thumb,
#report-body::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 3px;
}

/* 注目企業リストの項目 */
.top-company-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.55rem 0.5rem;
  border-radius: 0.55rem;
  cursor: pointer;
  transition: background-color .12s ease;
}
.top-company-item:hover { background-color: #f1f5f9; }
.top-company-dot {
  width: 9px; height: 9px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
}
.top-company-name { font-size: 0.78rem; font-weight: 700; color: #1e293b; line-height: 1.3; }
.top-company-meta { font-size: 0.68rem; color: #64748b; line-height: 1.5; }

/* 業種フィルターチェックボックス行 */
.sector-check-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.2rem;
  border-radius: 0.35rem;
}
.sector-check-row:hover { background-color: #f8fafc; }
.sector-swatch { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* 凡例 */
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: #475569;
  cursor: pointer;
  user-select: none;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  transition: background-color .12s ease;
}
.legend-item:hover { background-color: #f1f5f9; }
.legend-item.legend-inactive { opacity: 0.35; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* 球を左クリックしたときにチャート下へ出る、企業の主要財務情報テーブル */
.company-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  white-space: nowrap;
}
.company-detail-table th,
.company-detail-table td {
  padding: 0.35rem 0.7rem;
  border-bottom: 1px solid #f1f5f9;
}
.company-detail-table thead th {
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
/* 指標名の列は横スクロールしても見えているようにする */
.company-detail-table .detail-metric {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  font-weight: 600;
  color: #334155;
  background-color: #fff;
}
.company-detail-table thead .detail-metric { background-color: #f8fafc; }
.company-detail-table .detail-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #1e293b;
}
/* 会社予想の値は実績と一目で見分けられるよう色を変える */
.company-detail-table .detail-num-forecast { color: #2f56c8; }

/* 左端に置く「会社予想」列。実績の決算期列との境目に区切り線を入れる */
.company-detail-table .detail-forecast-col {
  border-right: 1px solid #e2e8f0;
  background-color: #fafbff;
}
.company-detail-table thead .detail-forecast-col {
  color: #2f56c8;
  background-color: #f2f5fe;
}

/* 列見出しは「相対位置／決算期／発表日」の3段組み */
.company-detail-table .detail-col-name { font-size: 0.68rem; font-weight: 700; }
.company-detail-table .detail-col-sub {
  font-size: 0.6rem;
  font-weight: 500;
  color: #94a3b8;
  line-height: 1.35;
}

/* 行ラベル先頭に付く「予想」「実績」バッジ */
.detail-badge {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: 1px;
}
.detail-badge-forecast { background-color: #e8effd; color: #2f56c8; }
.detail-badge-actual { background-color: #f1f5f9; color: #64748b; }
.company-detail-table .detail-group-row td {
  padding: 0.4rem 0.7rem 0.25rem;
  font-size: 0.66rem;
  font-weight: 700;
  color: #94a3b8;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.company-detail-table tbody tr:not(.detail-group-row):hover td,
.company-detail-table tbody tr:not(.detail-group-row):hover .detail-metric {
  background-color: #f8fafc;
}

/* 分析レポート内 */
.report-metric-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.65rem;
  padding: 0.8rem 1rem;
}
.report-metric-card .value { font-size: 1.35rem; font-weight: 800; color: #1e293b; }
.report-metric-card .label { font-size: 0.7rem; color: #64748b; font-weight: 600; }

.report-company-row td { padding: 0.5rem 0.6rem; font-size: 0.78rem; border-bottom: 1px solid #f1f5f9; }
.report-company-row:hover td { background-color: #f8fafc; }

/* 軸フィルターのレイアウト調整 */
#axis-x-filter,
#axis-y-filter,
#axis-z-filter {
  overflow-x: visible;
}

#axis-x-filter .flex,
#axis-y-filter .flex,
#axis-z-filter .flex {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 0.2rem !important;
  align-items: center !important;
}

#axis-x-filter input,
#axis-y-filter input,
#axis-z-filter input {
  flex: 1;
  min-width: 40px !important;
  font-size: 0.65rem !important;
  padding: 0.25rem 0.3rem !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 0.3rem !important;
  background-color: #fff !important;
  color: #334155 !important;
}

#axis-x-filter input:focus,
#axis-y-filter input:focus,
#axis-z-filter input:focus {
  outline: none !important;
  border-color: #3d6bf0 !important;
  box-shadow: 0 0 0 2px rgba(61,107,240,0.15) !important;
}

#axis-x-filter span,
#axis-y-filter span,
#axis-z-filter span {
  font-size: 0.6rem;
  color: #94a3b8;
  flex-shrink: 0;
}

/* 時価総額フィルター */
#control-panel > div:nth-child(2) {
  max-width: 100%;
}

#control-panel > div:nth-child(2) > div:nth-child(3) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

#control-panel > div:nth-child(2) > div:nth-child(3) input {
  flex: 0 1 calc(50% - 0.2rem);
  min-width: 60px;
  padding: 0.35rem 0.4rem;
  font-size: 0.7rem;
}

#control-panel > div:nth-child(2) > div:nth-child(3) span {
  flex-shrink: 0;
  font-size: 0.65rem;
  color: #94a3b8;
}

/* カスタムフィルターのスタイル */
.custom-filter-group {
  padding: 0.5rem;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  margin-top: 0.3rem;
}

.custom-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  margin-bottom: 0.3rem;
}

.custom-filter-header label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #475569;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.custom-filter-header button {
  flex-shrink: 0;
  padding: 0.15rem 0.4rem;
  font-size: 0.6rem;
  color: #64748b;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.15s;
}

.custom-filter-header button:hover {
  color: #e11d48;
}

/* 指標フィルター内の「種別／決算期」セレクタ。軸設定側(.axis-sub)と同じ見た目に
   揃えつつ、上の見出し行との間隔と、下の最小・最大入力との間隔だけ調整する。 */
.custom-filter-sub {
  margin-top: 0;
  margin-bottom: 0.45rem;
}
.custom-filter-sub .axis-sub-row:first-child { margin-top: 0; }

.custom-filter-inputs {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.custom-filter-inputs input {
  flex: 0 1 calc(50% - 0.2rem);
  min-width: 60px;
  font-size: 0.7rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  background-color: #fff;
  color: #334155;
}

.custom-filter-inputs input:focus {
  outline: none;
  border-color: #3d6bf0;
  box-shadow: 0 0 0 2px rgba(61,107,240,0.15);
}

.custom-filter-inputs .dash {
  font-size: 0.65rem;
  color: #94a3b8;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  #chart-3d { height: 480px !important; }
}
