:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #656d76;
  --border: #e1e4e8;
  --accent: #2f7d4f;
  --chart-bar: rgba(54, 128, 214, 0.55);
  --chart-bar-border: rgba(54, 128, 214, 0.9);
  --chart-line: #2f9e6a;
  --chart-grid: rgba(0, 0, 0, 0.07);
  --row-hover: #f2f5f8;
  --total-bg: #fff8e6;
}

/* ダークモード（画面右上のボタンで切り替え。初期値はライト） */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #181b21;
  --text: #e6e8eb;
  --muted: #9aa3ad;
  --border: #2c313a;
  --accent: #5fc58f;
  --chart-bar: rgba(96, 160, 240, 0.5);
  --chart-bar-border: rgba(96, 160, 240, 0.9);
  --chart-line: #5fc58f;
  --chart-grid: rgba(255, 255, 255, 0.08);
  --row-hover: #20242b;
  --total-bg: #2a2516;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.5;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

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

h1 { font-size: 1.5rem; margin: 0; }

.theme-toggle {
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }

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

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat .label { color: var(--muted); font-size: 0.8rem; }
.stat .value { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.chart { position: relative; height: 320px; }

.message { color: var(--muted); margin: 8px 0; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td.title { white-space: normal; min-width: 16em; }
.num { text-align: right; }
tbody tr:hover { background: var(--row-hover); }
tfoot td { background: var(--total-bg); font-weight: 600; }

th button {
  all: unset;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th[aria-sort] button { color: var(--accent); }

a { color: var(--accent); }

/* 並べ替えていない列の ⇅ は控えめに */
th button .sort-hint { color: var(--muted); font-weight: 400; }
