:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1f2a37;
    --muted: #5b6573;
    --border: #dfe3e8;
    --title: #1d3557;
    --ly: #6b6b6b;      /* 前年（グレー） */
    --ty: #d0021b;      /* 今年（赤） */
    --yoy: #1a6fa8;     /* 前年比（青） */
    --event: #e07b1a;   /* イベント線（オレンジ） */
    --plus: #1a6fa8;
    --minus: #c62828;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
    font-size: 14px;
}

.page { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }

.page-header h1 { margin: 0 0 12px; font-size: 22px; color: var(--title); font-weight: 700; }
.chart-title { margin: 0 0 2px; font-size: 18px; color: var(--title); font-weight: 700; }
.subtitle { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.meta-line { margin: -4px 0 14px; color: var(--muted); font-size: 13px; }

.error { background: #fdecea; color: #8a1c1c; border: 1px solid #f5c2c0; border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: #fafbfc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .swatch { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.chart-wrap { position: relative; height: 440px; }

.table-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.table-head h2 { margin: 0; font-size: 16px; color: var(--title); }
.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table thead th { background: #f0f2f5; font-weight: 500; text-align: left; position: sticky; top: 0; }
.data-table .num { text-align: right; }
.data-table tbody tr:hover { background: #f8f9fb; }
.data-table tfoot td { font-weight: 700; background: #f7f8fa; border-top: 2px solid var(--border); }
.data-table .sat { color: #1565c0; }
.data-table .sun { color: #c62828; }
.plus { color: var(--plus); }
.minus { color: var(--minus); }
.event-tag { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 11px; color: var(--event); border: 1px solid var(--event); border-radius: 10px; }

.notes { color: var(--muted); font-size: 12px; }
.notes p { margin: 4px 0; }

/* タブ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--title); margin-bottom: 16px; }
.tab {
    background: #e9ecf1; color: var(--muted); border: 1px solid var(--border); border-bottom: none;
    border-radius: 6px 6px 0 0; padding: 8px 22px; font-weight: 500;
}
.tab.active { background: var(--title); color: #fff; border-color: var(--title); }
.panel-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.panel-head label { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.panel-head select { font: inherit; padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px; background: #fff; min-width: 180px; }
.hint { color: var(--muted); font-size: 12px; }

/* 横持ち表（行=指標、列=日付） */
.matrix th, .matrix td { text-align: right; padding: 6px 10px; }
.matrix thead th { text-align: center; }
.matrix .row-label {
    position: sticky; left: 0; z-index: 1; text-align: left; background: #f0f2f5; font-weight: 500; min-width: 150px;
}
.matrix thead .row-label { z-index: 2; }
.matrix tbody td.row-label { background: #f7f8fa; }
.matrix .dow { font-size: 11px; font-weight: 400; }
.matrix .col-event { border-left: 2px dashed var(--event); }
.matrix .col-total { background: #f7f8fa; font-weight: 700; border-left: 2px solid var(--border); }
.matrix thead .col-total { background: #e6e9ee; }
.matrix tr.group td { text-align: left; background: #eef2f7; font-weight: 700; color: var(--title); }
.matrix tr.group-sep td { border-top: 2px solid var(--border); }
.matrix .ly-date { color: var(--muted); font-size: 12px; }

@media (max-width: 700px) {
    .kpis { grid-template-columns: 1fr; }
    .chart-wrap { height: 340px; }
}
