:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-blue: #2a78d6;
  --series-gold: #eda100;
  --status-good: #0ca30c;
  --status-good-text: #006300;
  --status-critical: #d03b3b;
  --neutral-mid: #f0efec;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-blue: #3987e5;
    --series-gold: #c98500;
    --status-good: #0ca30c;
    --status-good-text: #0ca30c;
    --status-critical: #e66767;
    --neutral-mid: #383835;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--page);
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

h1 { font-size: 26px; margin: 0; }
h2 { font-size: 20px; margin: 28px 0 12px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.updated { font-size: 14px; color: var(--text-secondary); }

button {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}
button:hover { border-color: var(--baseline); }

/* 再取得ボタンのツールチップ */
.tooltip-wrap { position: relative; display: inline-block; }

.tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

.tooltip-wrap:hover .tooltip,
.tooltip-wrap:focus-within .tooltip { display: block; }

.notice {
  background: var(--surface-1);
  border: 1px solid var(--status-critical);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 15px;
}

/* ---- ヒーロー・統計タイル ---- */
.hero-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
}
@media (max-width: 800px) {
  .hero-row { grid-template-columns: 1fr; }
}

.hero-tile, .stat-tile, .panel, .card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.tile-label { font-size: 15px; color: var(--text-secondary); }
.hero-value { font-size: 52px; line-height: 1.15; margin-top: 4px; }
.stat-value { font-size: 34px; line-height: 1.2; margin-top: 4px; }
.tile-sub { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.delta-up { color: var(--status-good-text); }
.delta-down { color: var(--status-critical); }

/* ---- 総合判定 ---- */
.panel h2 { margin-top: 0; }

.verdict-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: center;
}
@media (max-width: 800px) {
  .verdict-grid { grid-template-columns: 1fr; }
}

.meter-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.meter-track {
  position: relative;
  height: 18px;
  border-radius: 9px;
  background: var(--neutral-mid);
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 9px;
  background: var(--series-blue);
  transition: left 0.4s, width 0.4s;
}

.meter-needle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 4px;
  border-radius: 2px;
  background: var(--text-primary);
  transition: left 0.4s;
}

.meter-score {
  text-align: center;
  font-size: 24px;
  margin-top: 8px;
}

.verdict-text { font-size: 17px; margin: 0; }

/* ---- チャート ---- */
.chart-holder { position: relative; width: 100%; }
.chart-holder svg { display: block; width: 100%; height: auto; }
.chart-holder text { font-weight: 700; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 5;
  display: none;
}

/* ---- ファクターカード ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card-name { font-size: 17px; }
.card-desc { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

.badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid;
  white-space: nowrap;
}
.badge-good { color: var(--status-good-text); border-color: var(--status-good); }
.badge-bad { color: var(--status-critical); border-color: var(--status-critical); }
.badge-neutral { color: var(--text-secondary); border-color: var(--baseline); }

.card-value-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 8px;
}
.card-value { font-size: 28px; }
.card-date { font-size: 14px; color: var(--text-muted); }

.card-spark { margin-top: 8px; }
.card-spark svg { display: block; width: 100%; height: 64px; }

.card-foot { font-size: 14px; color: var(--text-secondary); margin-top: 8px; }
.card-error { color: var(--status-critical); font-size: 15px; margin-top: 8px; }

/* ---- テーブル ---- */
.table-wrap-x { overflow-x: auto; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
}
th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th { color: var(--text-secondary); font-size: 14px; }

footer {
  margin-top: 36px;
  font-size: 14px;
  color: var(--text-muted);
}
