/* =====================================================
   SBI Portfolio Dashboard - dashboard.css v1.2
   ===================================================== */

.spd-app {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: #333;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}
.spd-app *, .spd-app *::before, .spd-app *::after { box-sizing: border-box; }

/* =====================================================
   アップロード
   ===================================================== */
.spd-upload-section { padding: 40px 20px; text-align: center; }

.spd-upload-box {
  border: 2px dashed #c0c8d4;
  border-radius: 16px;
  padding: 60px 40px;
  background: #f8fafc;
  max-width: 580px;
  margin: 0 auto;
  transition: border-color .2s;
}
.spd-upload-box:hover { border-color: #4A90D9; }
.spd-upload-icon { font-size: 52px; margin-bottom: 16px; line-height: 1; }
.spd-upload-box h2 { font-size: 22px; font-weight: 700; margin: 0 0 12px; color: #1a2740; }
.spd-upload-box p  { color: #666; margin: 0 0 28px; line-height: 1.7; font-size: 14px; }
.spd-upload-box small { color: #999; font-size: 12px; }

.spd-upload-btn {
  display: inline-block;
  background: #4A90D9; color: #fff;
  padding: 13px 32px; border-radius: 8px;
  cursor: pointer; font-size: 15px; font-weight: 600;
  transition: background .2s, transform .1s; user-select: none;
}
.spd-upload-btn:hover   { background: #357abd; transform: translateY(-1px); }
.spd-upload-btn:active  { transform: translateY(0); }

.spd-error {
  color: #c0392b; background: #fdf3f2;
  border: 1px solid #e8bfbb; border-radius: 8px;
  padding: 10px 16px; margin-top: 20px; font-size: 13px; text-align: left;
}

/* =====================================================
   ダッシュボード共通
   ===================================================== */
.spd-dashboard { padding: 0 4px 40px; }

.spd-dashboard-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.spd-dashboard-header h2 { font-size: 20px; font-weight: 700; margin: 0; color: #1a2740; }

.spd-btn-secondary {
  background: #f0f2f5; border: 1px solid #dde1e8;
  padding: 8px 18px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500; color: #555;
  transition: background .2s;
}
.spd-btn-secondary:hover { background: #e2e6ec; }

/* =====================================================
   タブ
   ===================================================== */
.spd-tabs {
  display: flex; border-bottom: 2px solid #e4e8f0;
  margin-bottom: 24px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; gap: 0;
}
.spd-tab {
  background: none; border: none;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  padding: 11px 20px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: #888;
  white-space: nowrap; transition: color .2s, border-color .2s; outline: none;
}
.spd-tab:hover   { color: #4A90D9; }
.spd-tab.active  { color: #4A90D9; border-bottom-color: #4A90D9; font-weight: 700; }
.spd-tab-content { display: none; }
.spd-tab-content.active { display: block; }

/* =====================================================
   カード
   ===================================================== */
.spd-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.spd-card {
  background: #fff; border: 1px solid #e4e8f0; border-radius: 12px;
  padding: 20px 18px; text-align: center;
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.spd-card-label {
  font-size: 11px; color: #999; margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .6px; font-weight: 600;
}
.spd-card-value { font-size: 22px; font-weight: 700; color: #1a2740; letter-spacing: -.5px; }
.spd-card-sub   { font-size: 13px; margin-top: 6px; font-weight: 600; }

/* セクション見出し（口座内訳など） */
.spd-section-heading {
  font-size: 15px; font-weight: 600; color: #444;
  margin: 8px 0 16px;
}

/* =====================================================
   カラー
   ===================================================== */
.spd-positive { color: #27ae60 !important; }
.spd-negative { color: #e74c3c !important; }

/* =====================================================
   グラフ行（2カラム / SP縦積み）
   ===================================================== */
.spd-charts-scroll {
  margin-bottom: 24px;
}
.spd-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.spd-chart-box {
  background: #fff; border: 1px solid #e4e8f0; border-radius: 12px;
  padding: 20px; box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.spd-chart-box h3 { font-size: 14px; font-weight: 600; margin: 0 0 16px; color: #555; }
.spd-chart-box canvas { max-height: 230px; }

/* =====================================================
   セクション
   ===================================================== */
.spd-section {
  background: #fff; border: 1px solid #e4e8f0; border-radius: 12px;
  padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.spd-section h3 { font-size: 15px; font-weight: 600; margin: 0 0 16px; color: #444; }

/* =====================================================
   テーブル
   ===================================================== */
.spd-table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.spd-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 540px; }
.spd-table th {
  background: #f5f7fb; padding: 10px 12px; text-align: left;
  font-weight: 600; color: #666; border-bottom: 2px solid #e4e8f0; white-space: nowrap;
}
.spd-table td { padding: 10px 12px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.spd-table tr:hover td { background: #f8fafc; }
.spd-table tr:last-child td { border-bottom: none; }

/* 合計行 */
.spd-total-row td {
  background: #f0f4ff !important;
  border-top: 2px solid #c5cef0;
  border-bottom: none !important;
}

.spd-num       { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.spd-code-cell { font-family: 'SFMono-Regular', Consolas, monospace; color: #aaa; font-size: 12px; }
.spd-rank      { text-align: center; color: #888; font-size: 12px; font-weight: 700; }
.spd-stock-name { font-weight: 500; font-size: 13px; }
.spd-code-small { color: #bbb; font-family: 'SFMono-Regular', Consolas, monospace; font-size: 11px; }
.spd-sector-names { color: #666; font-size: 12px; }
.spd-empty { text-align: center; color: #bbb; padding: 48px 0; font-size: 14px; }

/* =====================================================
   バッジ
   ===================================================== */
.spd-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.spd-badge-nisa     { background: #eaf7ef; color: #1a7a40; }
.spd-badge-general  { background: #eaf1fb; color: #1a4a8a; }

/* 区分バッジ */
.spd-type-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.spd-type-cyclical  { background: #fff0eb; color: #c0392b; }
.spd-type-defensive { background: #eaf1fb; color: #1a4a8a; }

/* =====================================================
   検索・フィルター
   ===================================================== */
.spd-table-controls {
  display: flex; gap: 12px; margin-bottom: 16px;
  flex-wrap: wrap; align-items: center;
}
.spd-search-input, .spd-select {
  padding: 8px 12px; border: 1px solid #dde1e8; border-radius: 8px;
  font-size: 13px; outline: none; background: #fff; transition: border-color .2s;
}
.spd-search-input { flex: 1; min-width: 200px; }
.spd-search-input:focus, .spd-select:focus {
  border-color: #4A90D9; box-shadow: 0 0 0 3px rgba(74,144,217,.12);
}

/* =====================================================
   グラフタブ レイアウト（左:テーブル / 右:チャート）
   ===================================================== */
.spd-graph-row {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}
.spd-graph-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.spd-graph-chart canvas { max-height: 340px; }

/* =====================================================
   レスポンシブ
   ===================================================== */
@media (max-width: 900px) {
  .spd-graph-row {
    grid-template-columns: 1fr;
  }
  .spd-graph-chart { max-width: 400px; margin: 0 auto; }
}

@media (max-width: 768px) {
  .spd-cards { grid-template-columns: repeat(2, 1fr); }
  .spd-tab { padding: 9px 14px; font-size: 13px; }
  .spd-dashboard-header h2 { font-size: 17px; }
  .spd-charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .spd-cards { grid-template-columns: 1fr; }
  .spd-upload-box { padding: 40px 20px; }
  .spd-upload-box h2 { font-size: 18px; }
  .spd-table-controls { flex-direction: column; align-items: stretch; }
  .spd-search-input { min-width: unset; }
}
