/* app.css — 配置、コンポーネント、動き、印刷用（DESIGN.md 2〜5節）。
   色は tokens.css の変数だけ。HEX・rgb・hsl は書かない。影・ぼかし・グラデーション・半透明の面は使わない。
   余白は 4 / 8 / 12 / 16 / 24 / 32 / 48 だけ。太さは 400 と 600 だけ。文字は 12px 未満を使わない。 */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: dark; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font-family: var(--font); font-size: var(--fs-body); line-height: var(--lh-body); font-weight: var(--fw-regular);
  font-variant-numeric: tabular-nums; letter-spacing: normal;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, h5, p, dl, dd, ul { margin: 0; }
h1, h2, h3, h4, h5 { font-weight: var(--fw-strong); font-size: inherit; }
ul { padding: 0; list-style: none; }
b, strong { font-weight: var(--fw-strong); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary-fg); }
code { font-family: var(--font); background: var(--surface-raised); padding: 0 4px; border-radius: var(--r-badge); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nowrap { white-space: nowrap; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip-link { position: fixed; left: 16px; top: -48px; z-index: 300; padding: 8px 12px; background: var(--surface-raised); color: var(--text); border-radius: var(--r-ctl); }
.skip-link:focus { top: 8px; }
.noscript { padding: 24px; }

/* ---------------------------------------------------------------- 動き（5節。CSSだけ。1つの効果は0.2〜0.4秒） */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-06 { from { opacity: 0.6; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes sk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.pressable { transition: transform var(--t-fast) ease, background-color var(--t-fast) ease, color var(--t-fast) ease; }
.pressable:active { transform: scale(0.98); }                       /* プレスエフェクト：押している間だけ縮む */
.st { animation: rise var(--t-fast) ease both; animation-delay: calc(var(--i, 0) * 30ms); }   /* スタッガー表示：1行ごとに0.03秒。最大 0.21+0.2 = 0.41秒 */
.fade-once { animation: fade-06 var(--t-mid) ease both; }          /* スムーズスクロール＋フェードイン */
.empty { animation: fade-in var(--t-fast) ease both; }              /* エンプティステート */

/* ---------------------------------------------------------------- スケルトンスクリーン */
.skel { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-columns: 248px minmax(0, 1fr); background: var(--canvas); transition: opacity var(--t-fast) ease; }
.skel.out { opacity: 0; pointer-events: none; }
.sk { background: var(--surface-raised); border-radius: var(--r-card); animation: sk-pulse 1.6s ease-in-out infinite; }
.skel-side { padding: 16px; border-right: 1px solid var(--line); }
.sk-brand { height: 48px; margin-bottom: 24px; }
.sk-nav { height: 40px; margin-bottom: 8px; }
.skel-main { padding: 0 32px; }
.sk-bar { height: 56px; margin: 0 -32px 32px; border-radius: 0; }
.sk-kpi { height: 240px; margin-bottom: 16px; }
.sk-chart { height: 360px; }

/* ---------------------------------------------------------------- 全体の枠 */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.content { min-width: 0; position: relative; }
.main { max-width: 1264px; margin: 0 auto; padding: 32px 32px 48px; }

/* ---------------------------------------------------------------- サイドバー */
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; background: var(--canvas); border-right: 1px solid var(--line); z-index: 40; }
.sb-inner { display: flex; flex-direction: column; height: 100%; padding: 16px; overflow-y: auto; background: var(--canvas); }
.sb-top { display: none; }
.sb-brand { padding: 8px 12px; margin-bottom: 16px; }
.sb-name { font-size: var(--fs-card); line-height: var(--lh-card); font-weight: var(--fw-strong); }
.sb-sub { font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.sb-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px;
  border-left: 2px solid transparent; border-radius: 0 var(--r-ctl) var(--r-ctl) 0;
  color: var(--text-sub); text-decoration: none; font-size: var(--fs-sub);
}
.nav-item:hover { background: var(--surface-raised); color: var(--text); }
.nav-group.current > .nav-item { background: var(--surface-raised); border-left-color: var(--primary-fg); color: var(--text); }   /* スクロールスパイ：面と左の線 */
.nav-label { flex: 1; min-width: 0; }
.nav-flag { font-size: var(--fs-axis); line-height: var(--lh-axis); color: var(--text-mute); white-space: nowrap; }
.nav-children { display: none; padding: 4px 0 8px 32px; }
.nav-group.current .nav-children { display: block; }                 /* 子項目は開いているグループだけ */
.nav-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; padding: 4px 8px; border-radius: var(--r-ctl); color: var(--text-sub); text-decoration: none; font-size: var(--fs-note); line-height: var(--lh-note); }
.nav-sub:hover { background: var(--surface-raised); color: var(--text); }
.dim { color: var(--text-mute); }                                    /* 店舗別データが無い項目は1段暗く */
.nav-group.current > .nav-item.dim, .nav-group.current > .nav-item .nav-flag, .nav-sub:hover .nav-flag, .nav-item:hover .nav-flag { color: var(--text-sub); }
.nav-group.dim > .nav-item { color: var(--text-mute); }
.nav-group.current.dim > .nav-item { color: var(--text-sub); }
.sb-foot { margin-top: auto; padding-top: 16px; }
.sb-foot-title { font-size: var(--fs-note); line-height: var(--lh-note); font-weight: var(--fw-strong); color: var(--text-sub); margin-bottom: 8px; }
.datarange > div { padding: 8px 0; border-top: 1px solid var(--line); }
.datarange dt { font-size: var(--fs-axis); line-height: var(--lh-axis); color: var(--text-mute); }
.datarange dd { font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.menu-btn, .menu-close { display: none; align-items: center; gap: 12px; height: 40px; padding: 0 8px; background: transparent; border: 1px solid transparent; border-radius: var(--r-ctl); color: var(--text-sub); cursor: pointer; }
.menu-btn:hover, .menu-close:hover { background: var(--surface-raised); color: var(--text); }
.foot-range { display: none; }

/* ---------------------------------------------------------------- 絞り込みバー */
.filterwrap { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; padding: 8px 32px; background: var(--canvas); border-bottom: 1px solid var(--line); }
.fb-panel { order: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; }
.fb-line { order: 2; display: flex; align-items: center; gap: 12px; min-width: 0; }
.fb-line .fb-toggle { display: none; }
.fb-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.fb-label { font-size: var(--fs-note); line-height: var(--lh-note); font-weight: var(--fw-strong); color: var(--text-sub); }
.fb-sep { color: var(--text-sub); }
.fb-rule { width: 1px; height: 24px; background: var(--line-strong); }
.filterwrap.fb-wrapped .fb-rule { display: none; }
.fb-summary { font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); min-width: 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.btn, .field {
  height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--canvas); color: var(--text-sub); font-size: var(--fs-sub); line-height: 20px;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.btn:hover { color: var(--text); }
.btn.on { background: var(--surface-raised); color: var(--text); }   /* 選んだボタン：面を1段明るくし文字を paper-50。色は付けない */
.field { padding: 0 8px; color: var(--text); }
select.field { padding: 0 8px; }
.link-btn { height: 36px; padding: 0 8px; border: 0; background: transparent; color: var(--primary-fg); font-size: var(--fs-sub); cursor: pointer; text-decoration: underline; white-space: nowrap; border-radius: var(--r-ctl); }
.sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sc); margin-right: 8px; flex: none; }

/* ---------------------------------------------------------------- グループとカード */
.group { margin-bottom: 48px; scroll-margin-top: calc(var(--fb-h) + 16px); }
.group:last-of-type { margin-bottom: 0; }
.group-head { margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.group-title { font-size: var(--fs-group); line-height: var(--lh-group); font-weight: var(--fw-strong); }
.legend-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.legend-line > span:not(.badge) { margin-right: 8px; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.grid-after { margin-top: 16px; }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c6 { grid-column: span 6; } .c4 { grid-column: span 4; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 24px; min-width: 0; scroll-margin-top: calc(var(--fb-h) + 16px); }
.card-table { padding: 24px 0; }
#card-storedetail { align-self: start; }
.card-table .pad, .pad { padding-left: 24px; padding-right: 24px; }
.card-table .card-head { padding-left: 24px; padding-right: 24px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.card-title { font-size: var(--fs-card); line-height: var(--lh-card); font-weight: var(--fw-strong); }
.when { font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.desc { margin: 4px 0 16px; font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.note { margin-top: 16px; font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.sub { color: var(--text-sub); font-size: var(--fs-note); }
.warn-text { color: var(--warning); }
.chart-box { position: relative; width: 100%; }
.h140 { height: 140px; } .h200 { height: 200px; } .h240 { height: 240px; } .h280 { height: 280px; } .h320 { height: 320px; } .h360 { height: 360px; } .h420 { height: 420px; }
.insight { margin-top: 16px; padding-left: 12px; border-left: 2px solid var(--line); font-size: var(--fs-body); line-height: var(--lh-body); color: var(--text-sub); }
.insight b { color: var(--text); }
.insight-lab { display: block; font-size: var(--fs-note); line-height: var(--lh-note); font-weight: var(--fw-strong); color: var(--text-sub); }
.card-table .insight, .insight.pad { margin-left: 24px; margin-right: 24px; padding-left: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.sub-block { margin-top: 24px; }
.sub-title { font-size: var(--fs-sub); line-height: var(--lh-sub); font-weight: var(--fw-strong); margin-bottom: 12px; }
.mini-title { font-size: var(--fs-note); line-height: var(--lh-note); font-weight: var(--fw-strong); color: var(--text-sub); margin-bottom: 4px; }
.mini-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.pos-pair { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px; }
.scope-empty .empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.focus-note { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 8px 8px 8px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.focus-note b { color: var(--text); }
.print-summary { display: none; }

/* ---------------------------------------------------------------- バッジ（3.2）：面は各色の900、文字は200。色だけで伝えず必ず言葉を入れる */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-badge); font-size: var(--fs-note); line-height: var(--lh-note); font-weight: var(--fw-regular); white-space: nowrap; background: var(--badge-mid-bg); color: var(--badge-mid-fg); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.b-good { background: var(--badge-good-bg); color: var(--badge-good-fg); }
.b-mid, .b-fixed { background: var(--badge-mid-bg); color: var(--badge-mid-fg); }
.b-warn { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.b-bad { background: var(--badge-bad-bg); color: var(--badge-bad-fg); }
.b-link { background: var(--badge-link-bg); color: var(--badge-link-fg); }
.delta { font-weight: var(--fw-strong); white-space: nowrap; }
.delta.up { color: var(--delta-up); }
.delta.down { color: var(--delta-down); }
.delta.neutral { color: var(--text-sub); }

/* ---------------------------------------------------------------- 概要（KPI）：大きい1枚＋線で区切った行 */
.kpi-board { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); scroll-margin-top: calc(var(--fb-h) + 16px); }
.kpi-board.is-empty { display: block; }
.kpi-main { padding: 24px; border-right: 1px solid var(--line); min-width: 0; }
.kpi-side { display: flex; flex-direction: column; min-width: 0; }
.kpi-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); flex: 1; }
.kpi-row:last-child { border-bottom: 0; }
.kpi-row .kpi-label { grid-column: 1; grid-row: 1; }
.kpi-row .kpi-sub { grid-column: 1; grid-row: 2; }
.kpi-row .kpi-val { grid-column: 2; grid-row: 1 / span 2; text-align: right; }
.kpi-label { font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.kpi-sub { font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.kpi-val { font-size: var(--fs-kpi); line-height: var(--lh-kpi); font-weight: var(--fw-strong); }
.kpi-val .delta { font-size: var(--fs-sub); line-height: var(--lh-sub); margin-left: 8px; }
.kpi-val-2 { display: block; font-size: var(--fs-sub); line-height: var(--lh-sub); font-weight: var(--fw-regular); color: var(--text-sub); }
.kpi-hero { margin-top: 4px; font-size: var(--fs-hero); line-height: var(--lh-hero); font-weight: var(--fw-strong); }
.unit { margin-left: 4px; font-size: var(--fs-sub); line-height: var(--lh-sub); font-weight: var(--fw-regular); color: var(--text-sub); }
.kpi-when { margin-top: 4px; font-size: var(--fs-sub); line-height: var(--lh-sub); color: var(--text-sub); }
.kpi-cmp { font-size: var(--fs-sub); line-height: var(--lh-sub); color: var(--text-sub); }
.kpi-mini-cap { margin: 16px 0 4px; font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.meter { display: block; margin-top: 4px; width: 112px; margin-left: auto; height: 4px; background: var(--d-track); border-radius: var(--r-dot); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--danger); }
.rows { display: grid; margin: 16px 0 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rows-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.rows-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-cell { padding: 16px; border-left: 1px solid var(--line); min-width: 0; }
.rows .kpi-val { white-space: nowrap; }
.rows-5 .row-cell:first-child, .rows-3 .row-cell:nth-child(3n + 1) { border-left: 0; padding-left: 0; }
.rows-3 .row-cell:nth-child(n + 4) { border-top: 1px solid var(--line); }
.row-cell .kpi-val { margin-top: 4px; }

/* ---------------------------------------------------------------- 店舗の6区画（線で区切る。箱にしない） */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0 0 16px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; text-align: left; background: transparent; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; min-width: 0; }
.tile:hover { background: var(--surface-raised); }
.tile.on::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--sc); }   /* 選んだ店は上に店の色の線 */
.tile-name { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; font-size: var(--fs-sub); line-height: var(--lh-sub); }
.tile-on { margin-left: 4px; font-size: var(--fs-axis); line-height: var(--lh-axis); color: var(--text-sub); }
.tile-val { font-size: var(--fs-kpi); line-height: var(--lh-kpi); font-weight: var(--fw-strong); }
.tile-sub { font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }

/* ---------------------------------------------------------------- 表 */
.tbl-wrap { overflow: auto; max-width: 100%; }
.tbl-wrap.tall { max-height: 440px; }
#card-bcresult .tbl-wrap.tall { max-height: 420px; }   /* 7 店舗別 配信結果：最大高さ420pxで中をスクロール */
.tbl-wrap.flush { margin: 16px -24px 0; max-width: none; }
.card-table .tbl-wrap { margin: 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-body); line-height: var(--lh-body); }
th { position: sticky; top: 0; z-index: 1; padding: 12px; background: var(--surface-raised); color: var(--text-sub); font-size: var(--fs-note); line-height: var(--lh-note); font-weight: var(--fw-strong); text-align: left; vertical-align: bottom; }
td { height: 44px; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--text-sub); white-space: nowrap; vertical-align: middle; }
tbody tr:hover td { background: var(--surface-raised); }
tbody tr:hover td, td b { color: var(--text); }
td.wrap { white-space: normal; min-width: 192px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ctr { text-align: center; }
.tbl-wrap.flush th:first-child, .tbl-wrap.flush td:first-child, .card-table th:first-child, .card-table td:first-child { padding-left: 24px; }
.tbl-wrap.flush th:last-child, .tbl-wrap.flush td:last-child, .card-table th:last-child, .card-table td:last-child { padding-right: 24px; }
td.hi { color: var(--text); font-weight: var(--fw-strong); }
.bar-cell { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.minibar { display: inline-block; height: 4px; border-radius: var(--r-dot); background: var(--d-neutral); }
.rank { display: inline-block; min-width: 24px; font-weight: var(--fw-strong); color: var(--text); }
.tbl-hint { margin: 8px 0 4px; text-align: right; font-size: var(--fs-axis); line-height: var(--lh-axis); color: var(--text-mute); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.detail-panel > summary, .detail-inline > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; color: var(--text); font-size: var(--fs-sub); }
.detail-panel > summary { height: 44px; padding: 0 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-inline > summary { height: 44px; justify-content: flex-start; margin-top: 16px; border-top: 1px solid var(--line); }
.detail-inline > p { padding-bottom: 16px; font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
summary::-webkit-details-marker { display: none; }
details[open] > summary .chev { transform: rotate(180deg); }
.warn-detail summary { cursor: pointer; color: var(--primary-fg); font-size: var(--fs-note); line-height: var(--lh-note); }
.warn-body { padding: 4px 0; font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); max-width: 480px; }

/* ---------------------------------------------------------------- 性別比率 / ECページPV / ボタン行 */
.gbar { display: flex; height: 24px; border-radius: var(--r-ctl); overflow: hidden; background: var(--d-track); }
.gseg { min-width: 2px; border-right: 1px solid var(--d-sep); }
.gseg:last-child { border-right: 0; }
.glist { display: flex; flex-direction: column; margin-top: 16px; }
.glist li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.glist li:last-child { border-bottom: 0; }
.gdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.glab { flex: 1; color: var(--text-sub); }
.gval { font-size: var(--fs-kpi); line-height: var(--lh-kpi); font-weight: var(--fw-strong); }
.fnl-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.fnl-lab { font-size: var(--fs-sub); line-height: var(--lh-sub); font-weight: var(--fw-strong); }
.fnl-sub { font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.fnl-val { font-size: var(--fs-kpi); line-height: var(--lh-kpi); font-weight: var(--fw-strong); }
.fnl-conv { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.brows { margin-bottom: 16px; }
.brow { display: grid; grid-template-columns: minmax(0, 176px) minmax(0, 1fr) auto; align-items: center; gap: 12px; height: 44px; border-bottom: 1px solid var(--line); }
.brow-lab { color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow-bar { height: 8px; border-radius: var(--r-ctl); background: var(--d-track); overflow: hidden; }
.brow-bar i { display: block; height: 100%; background: var(--d-neutral); }
#access_note .brow:first-child .brow-bar i { background: var(--d-primary); }
.brow-val { min-width: 48px; text-align: right; }
.profile-bars { display: flex; flex-direction: column; }
.profile-barrow { display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px 56px; gap: 8px; align-items: center; height: 32px; font-size: var(--fs-note); }
.profile-barrow em { font-style: normal; color: var(--text-sub); text-align: right; }
.profile-barrow .bar { height: 8px; border-radius: var(--r-ctl); background: var(--d-track); overflow: hidden; }
.profile-barrow .bar i { display: block; height: 100%; background: var(--d-neutral); }
.profile-barrow b { text-align: right; }
.profile-chart { margin-top: 16px; }
.profile-body .tbl-wrap.flush { margin-top: 16px; }

/* ---------------------------------------------------------------- エンプティステート / トースト */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center; color: var(--text-sub); }
.empty p { max-width: 560px; font-size: var(--fs-sub); line-height: var(--lh-sub); }
.empty .ico { color: var(--text-mute); }
.pos-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center; color: var(--text-sub); animation: fade-in var(--t-fast) ease both; }
.pos-empty p { max-width: 560px; }
.pos-empty .ico { color: var(--text-mute); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 200; display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px); padding: 12px 16px; background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: var(--r-card); color: var(--text); font-size: var(--fs-sub); line-height: var(--lh-sub); opacity: 0; transform: translate(-50%, 16px); transition: opacity var(--t-fast) ease, transform var(--t-fast) ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .ico { color: var(--danger); }
.to-top { position: fixed; right: 24px; bottom: 24px; z-index: 35; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: var(--r-ctl); color: var(--text); cursor: pointer; }
.foot { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); font-size: var(--fs-note); line-height: var(--lh-note); color: var(--text-sub); }
.foot-range > div { padding: 8px 0; border-top: 1px solid var(--line); }
.foot-range { margin-top: 16px; }

/* ================================================================ 画面幅ごとの形 */

/* KPI が5つ並ぶ行は、数字の桁が収まらない幅では3列に折り返す */
@media (max-width: 1359px) {
  .rows-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rows-5 .row-cell:nth-child(3n + 1) { border-left: 0; padding-left: 0; }
  .rows-5 .row-cell:nth-child(n + 4) { border-top: 1px solid var(--line); }
}

/* 768〜1199：サイドバーは幅64pxのアイコンだけのレール。「メニュー」で幅248pxを重ねて開く */
@media (min-width: 768px) and (max-width: 1199px) {
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .skel { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar:not(.open) .sb-inner { align-items: center; padding: 16px 12px; }
  .sidebar:not(.open) .nav-label, .sidebar:not(.open) .sb-brand, .sidebar:not(.open) .nav-children, .sidebar:not(.open) .sb-foot, .sidebar:not(.open) .nav-item .nav-flag { display: none; }
  .sidebar:not(.open) .menu-btn { display: flex; width: 40px; padding: 0; justify-content: center; margin-bottom: 16px; }
  .sidebar:not(.open) .nav-item { width: 40px; padding: 0; justify-content: center; gap: 0; border-radius: var(--r-ctl); }
  .sidebar:not(.open) .nav-group.current > .nav-item { border-left-color: var(--primary-fg); }
  .sidebar.open .sb-inner { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; z-index: 60; border-right: 1px solid var(--line-strong); }
  .sidebar.open .sb-top { display: flex; justify-content: flex-end; margin-bottom: 8px; }
  .sidebar.open .menu-close { display: flex; }
  .sidebar.open .menu-btn { display: none; }
}

/* 1199以下：横に並ぶカードの組み替え */
@media (max-width: 1199px) {
  .c4, .c8 { grid-column: span 12; }           /* 性別と年代 */
  .pos-pair { grid-template-columns: minmax(0, 1fr); }   /* POS の 7列＋5列 */
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .foot-range { display: grid; }
}

/* 768〜1023：上に残るバーが3行に収まらないので、1行だけ残す形にする（136px 以内） */
@media (max-width: 1023px) {
  .filterwrap { display: contents; }
  .fb-line { position: sticky; top: 0; z-index: 30; order: 0; justify-content: space-between; min-height: 56px; max-height: 56px; padding: 8px 16px; background: var(--canvas); border-bottom: 1px solid var(--line); }
  .fb-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .fb-line .fb-toggle { display: inline-flex; flex: none; }
  .fb-toggle[aria-expanded="true"] .ico { transform: rotate(180deg); }
  .fb-panel { display: none; padding: 16px; background: var(--canvas); border-bottom: 1px solid var(--line); gap: 16px; }
  .filterwrap.open .fb-panel { display: flex; }
  .fb-rule { display: none; }
  .fb-panel { flex-direction: column; align-items: flex-start; }
}

/* 767以下：サイドバーをやめ、上部に横スクロールのナビ。カードは全部1列 */
@media (max-width: 767px) {
  .app { display: block; }
  .skel { grid-template-columns: minmax(0, 1fr); }
  .skel-side { display: none; }
  .skel-main { padding: 0 16px; }
  .sk-bar { margin: 0 -16px 16px; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sb-inner { height: auto; padding: 8px 16px; gap: 4px; overflow: visible; }
  .sb-brand { padding: 4px 0; margin: 0; display: flex; align-items: baseline; gap: 12px; }
  .sb-nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .nav-group { flex: none; }
  .nav-children, .sb-foot { display: none !important; }
  .nav-item { border-left: 0; border-bottom: 2px solid transparent; border-radius: var(--r-ctl) var(--r-ctl) 0 0; white-space: nowrap; }
  .nav-group.current > .nav-item { border-bottom-color: var(--primary-fg); }
  .nav-item .nav-flag { display: none; }
  .main { padding: 24px 16px 48px; }
  .group { margin-bottom: 32px; }
  .grid { gap: 16px; }
  .c4, .c6, .c8, .c12 { grid-column: span 12; }
  .card { padding: 16px; }
  .card-table { padding: 16px 0; }
  .card-table .pad, .pad, .card-table .card-head { padding-left: 16px; padding-right: 16px; }
  .tbl-wrap.flush { margin-left: -16px; margin-right: -16px; }
  .tbl-wrap.flush th:first-child, .tbl-wrap.flush td:first-child, .card-table th:first-child, .card-table td:first-child { padding-left: 16px; }
  .tbl-wrap.flush th:last-child, .tbl-wrap.flush td:last-child, .card-table th:last-child, .card-table td:last-child { padding-right: 16px; }
  .split, .mini-row { grid-template-columns: minmax(0, 1fr); }
  .kpi-board { grid-template-columns: minmax(0, 1fr); }
  .kpi-main { border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; }
  .kpi-row { padding: 12px 16px; }
  .kpi-hero { font-size: var(--fs-hero); }
  .rows-5, .rows-3 { grid-template-columns: minmax(0, 1fr); }
  .row-cell, .rows-5 .row-cell:first-child, .rows-3 .row-cell:nth-child(3n + 1) { border-left: 0; padding: 12px 0; }
  .row-cell + .row-cell, .rows-3 .row-cell:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }       /* 店舗の6区画は2列×3段 */
  .h420 { height: 360px; }
  .focus-note { flex-direction: column; align-items: flex-start; }
  .brow { grid-template-columns: minmax(0, 112px) minmax(0, 1fr) auto; }
  .profile-barrow { grid-template-columns: 64px minmax(0, 1fr) 56px 48px; }
  .toast { bottom: 16px; }
  .to-top { right: 16px; bottom: 16px; }
}

/* ================================================================ prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }                        /* スケルトンは止まった面だけ */
  .skel, .skel.out { transition: none; }
  .st, .fade-once, .empty, .pos-empty { animation: none; }   /* スタッガー表示とフェードインをやめ、すぐ出す */
  .pressable { transition: background-color var(--t-fast) ease, color var(--t-fast) ease; }
  .pressable:active { transform: none; background: var(--surface-raised); color: var(--text); }   /* 縮みをやめ、面の色の変化だけ */
  .toast { transition: none; transform: translate(-50%, 0); }   /* トーストは動かさずに出して消す */
  html { scroll-behavior: auto; }
}

/* ================================================================ 印刷：背景 Paper 50、文字 Graphite 900（色は tokens.css の @media print） */
@media print {
  html { color-scheme: light; }
  body { background: var(--canvas); color: var(--text); }
  .sidebar, .filterwrap, .to-top, .skip-link, .toast, .menu-btn, .skel, .tbl-hint { display: none !important; }
  .app { display: block; }
  .main { max-width: none; padding: 0; }
  .print-summary { display: block; margin-bottom: 16px; font-size: var(--fs-note); color: var(--text-sub); }
  .card, .kpi-board { break-inside: avoid; }
  .group-head, .card-head { break-after: avoid; }
  .tbl-wrap, .tbl-wrap.tall { max-height: none; overflow: visible; }
  th { position: static; }
  .foot-range { display: grid; }
  canvas { max-width: 100% !important; height: auto !important; }   /* 画面の幅で描いた canvas を用紙の幅に収める */
  .chart-box { height: auto !important; }
  .grid { gap: 12px; }
  .c4, .c6, .c8 { grid-column: span 12; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
