/* 投資判断ダッシュボード — モバイルファースト */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --bar: #2a78d6;            /* セクター構成比バー(単一色相) */
  --up: #d03b3b;             /* 上昇 = 赤 (国内証券アプリ慣習・▲記号併記) */
  --down: #2a78d6;           /* 下落 = 青 (▼記号併記) */
  --warn-bg: #fdf3dc;
  --warn-border: #fab219;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --bar: #3987e5;
    --up: #e66767;
    --down: #3987e5;
    --warn-bg: #2c2410;
    --warn-border: #c98500;
    --accent: #3987e5;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 720px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; }
#date-select {
  font: inherit; font-size: 13px;
  color: var(--ink); background: var(--page);
  border: 1px solid var(--grid); border-radius: 8px; padding: 4px 8px;
}

.container { max-width: 720px; margin: 0 auto; padding: 12px 12px 48px; }
section { margin-bottom: 20px; }

.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--muted); text-transform: uppercase;
  margin: 0 4px 8px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.sub-label { font-size: 12px; font-weight: 700; color: var(--muted); margin: 18px 0 8px; }
.muted-note { font-size: 11px; font-weight: 400; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.banner { border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.banner-sample, .banner-warn { background: var(--warn-bg); border: 1px solid var(--warn-border); }

.loading { text-align: center; color: var(--muted); padding: 48px 0; }

/* 今日の結論 */
.verdict-card { border-left: 4px solid var(--accent); }
.verdict { margin: 0; font-size: 15px; font-weight: 600; }
.date-chip { font-weight: 400; }

/* マーケット: スタットタイル */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; min-width: 0;
}
.tile .t-label { font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.tile .t-value { font-size: 17px; font-weight: 700; margin: 2px 0; white-space: nowrap; }
.tile .t-delta { font-size: 12px; font-weight: 600; white-space: nowrap; }
.delta-up { color: var(--up); }
.delta-down { color: var(--down); }
.delta-flat { color: var(--muted); }
.market-comment { font-size: 13px; color: var(--ink-2); margin: 10px 4px 0; }

/* 購入提案カード */
.rec-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 10px;
}
.rec-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rec-rank {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  align-self: center;
}
.rec-name { font-size: 16px; font-weight: 700; }
.rec-code { font-size: 12px; color: var(--muted); }
.rec-sector {
  font-size: 11px; color: var(--ink-2);
  border: 1px solid var(--grid); border-radius: 999px; padding: 1px 8px;
}
.rec-order { font-size: 14px; margin: 6px 0 2px; font-weight: 600; }
.rec-order .amount { font-variant-numeric: tabular-nums; }
.rec-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  font-size: 11px; color: var(--ink-2);
  background: var(--page); border: 1px solid var(--grid);
  border-radius: 999px; padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.rec-reason { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }
.rec-risk { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.rec-risk::before { content: "⚠ "; }

.cand-details { margin-top: 4px; }
.cand-details summary {
  font-size: 13px; color: var(--accent); cursor: pointer; padding: 4px;
}

/* リスク警告 */
.warn-list { list-style: none; margin: 0; padding: 0; }
.warn-list li {
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; font-size: 13px;
}
.warn-list li::before { content: "⚠ "; }
.warn-list li.ok { background: var(--surface); border-color: var(--border); color: var(--ink-2); }
.warn-list li.ok::before { content: "✓ "; }

/* ポートフォリオ */
.pf-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 4px; }
.pf-total-label { font-size: 12px; color: var(--ink-2); margin-right: 8px; }
.pf-total-value { font-size: 24px; font-weight: 700; }
.pf-pl, .pf-cash { font-size: 13px; font-variant-numeric: tabular-nums; }
.pf-cash { color: var(--ink-2); }

/* セクター構成比バー (単一色相・データ端4px丸め) */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 9em 1fr 3.4em; align-items: center; gap: 8px; }
.bar-label { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: transparent; border-radius: 0 4px 4px 0; height: 14px; position: relative; }
.bar-fill {
  height: 100%; background: var(--bar);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.bar-value { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

/* テーブル */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 8px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th {
  font-size: 11px; font-weight: 600; color: var(--muted);
  border-bottom: 1px solid var(--grid);
}
tbody td { border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
.cell-name { max-width: 11em; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { display: block; font-size: 10px; color: var(--muted); }

/* ニュース */
.news-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 16px; margin-bottom: 10px;
}
.news-title { font-size: 14px; font-weight: 700; margin: 0; }
.news-title a { color: inherit; text-decoration: none; }
.news-title a:hover { text-decoration: underline; }
.news-summary { font-size: 13px; color: var(--ink-2); margin: 4px 0; }
.news-impact { font-size: 12px; margin: 4px 0 0; color: var(--ink-2); }
.news-impact::before { content: "→ 影響: "; font-weight: 700; }
.news-source { font-size: 11px; color: var(--muted); }

.note-list { margin: 0; padding-left: 1.2em; font-size: 13px; color: var(--ink-2); }
.note-list li { margin-bottom: 4px; }

.footer { border-top: 1px solid var(--grid); padding-top: 12px; }
.footer p { font-size: 11px; color: var(--muted); }

@media (max-width: 420px) {
  .tiles { gap: 6px; }
  .tile { padding: 8px 9px; }
  .tile .t-value { font-size: 15px; }
  .bar-row { grid-template-columns: 7.5em 1fr 3.2em; }
}
