/* 売上と在庫の見える画面
   包み紙の水色の地に、こげ茶の文字。期間のまとめは、レジのレシートの形で出す。 */

:root {
  --ground: #e4eef0;
  --paper: #ffffff;
  --ink: #36261c;
  --sub: #6a5a50;
  --line: #c7d3d6;
  --caramel: #c98322;
  --caramel-pale: #f3dcb6;
  --weekend: #a8611a;
  --good: #256e45;
  --good-soft: #e0f1e6;
  --bad: #ad2238;
  --bad-soft: #fbe4e7;
  --warn: #8a5200;
  --warn-soft: #fdeed2;
  --body: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  --print: "DotGothic16", "M PLUS Rounded 1c", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.7; }
h1, h2, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ---------- 頭 ---------- */

.top { background: var(--ink); color: #fff; }
.top-in { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 24px; padding-top: 16px; padding-bottom: 14px; }
.top h1 { font-size: 26px; line-height: 1.3; font-weight: 800; letter-spacing: 0.03em; }
.top-sub { margin-left: 14px; font-size: 16px; font-weight: 500; color: #f3dcb6; }
.source { font-size: 14px; color: #e3d8cf; }

.banner { margin-top: 16px; padding: 10px 14px; background: var(--paper); border-left: 6px solid var(--caramel); font-size: 14px; }
.banner-bad { border-left-color: var(--bad); background: var(--bad-soft); font-weight: 700; }
.banner-warn { border-left-color: var(--warn); background: var(--warn-soft); }

.empty-state { margin: 40px 0; padding: 28px; background: var(--paper); border: 2px dashed var(--ink); }
.empty-state h2 { font-size: 22px; margin-bottom: 8px; }
.heads { margin-top: 10px; font-weight: 700; }

/* ---------- 期間 ---------- */

.period { margin-top: 22px; }
.period-buttons { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.period-buttons button {
  min-height: 46px; padding: 0 20px; border: 2px solid var(--ink); border-radius: 999px; background: none;
  font-size: 16px; font-weight: 700;
}
.period-buttons button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.period-buttons button:hover:not([aria-pressed="true"]) { background: var(--paper); }
.period-note { margin-top: 8px; font-size: 14px; color: var(--sub); max-width: 60em; }

/* ---------- まとめ(レシート)と、右の欄 ---------- */

.deck { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 32px; margin-top: 22px; align-items: start; }
.deck > * { min-width: 0; }
.deck-main { display: grid; gap: 22px; }

.receipt { position: sticky; top: 16px; filter: drop-shadow(0 6px 10px rgba(54, 38, 28, 0.16)); }
.receipt-paper {
  background: var(--paper);
  padding: 26px 22px 34px;
  font-family: var(--print);
  --tooth: 12px;
  clip-path: polygon(
    0 6px, 4% 0, 8% 6px, 12% 0, 16% 6px, 20% 0, 24% 6px, 28% 0, 32% 6px, 36% 0, 40% 6px, 44% 0, 48% 6px, 52% 0, 56% 6px, 60% 0, 64% 6px, 68% 0, 72% 6px, 76% 0, 80% 6px, 84% 0, 88% 6px, 92% 0, 96% 6px, 100% 0,
    100% calc(100% - 6px), 96% 100%, 92% calc(100% - 6px), 88% 100%, 84% calc(100% - 6px), 80% 100%, 76% calc(100% - 6px), 72% 100%, 68% calc(100% - 6px), 64% 100%, 60% calc(100% - 6px), 56% 100%, 52% calc(100% - 6px), 48% 100%, 44% calc(100% - 6px), 40% 100%, 36% calc(100% - 6px), 32% 100%, 28% calc(100% - 6px), 24% 100%, 20% calc(100% - 6px), 16% 100%, 12% calc(100% - 6px), 8% 100%, 4% calc(100% - 6px), 0 100%
  );
}
.receipt h2 { font-family: var(--print); font-size: 20px; font-weight: 400; text-align: center; letter-spacing: 0.2em; }
.receipt-range { text-align: center; font-size: 14px; margin-top: 2px; padding-bottom: 12px; border-bottom: 2px dashed var(--ink); }
.line { padding: 12px 0; border-bottom: 1px dashed var(--sub); }
.line dt { font-size: 15px; }
.line dd { display: flex; flex-direction: column; align-items: flex-end; }
.value { font-size: 26px; line-height: 1.3; letter-spacing: 0.02em; }
.value small { font-size: 15px; margin-left: 3px; }
.line-main .value { font-size: 38px; }
.sub { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 2px 10px; font-family: var(--body); }
.before { font-size: 13px; color: var(--sub); }
.receipt-foot { margin-top: 12px; text-align: center; font-size: 14px; }

.delta { display: inline-flex; align-items: center; gap: 4px; font-family: var(--body); font-size: 14px; font-weight: 800; padding: 0 8px; border-radius: 999px; line-height: 1.7; white-space: nowrap; }
.delta i { font-style: normal; font-size: 11px; }
.delta-up { background: var(--good-soft); color: var(--good); }
.delta-down { background: var(--bad-soft); color: var(--bad); }
.delta-flat, .delta-none { background: #edf1f2; color: var(--sub); font-weight: 500; }

h2 { font-size: 22px; line-height: 1.4; font-weight: 800; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 20px; margin-bottom: 10px; }

/* まず見るところ */
.notices ul { margin-top: 10px; display: grid; gap: 6px; }
.notice { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; background: var(--paper); border-left: 6px solid var(--sub); font-size: 15px; line-height: 1.6; }
.notice-mark { display: grid; place-items: center; width: 30px; height: 30px; font-weight: 800; font-size: 15px; color: #fff; background: var(--sub); }
.notice strong { display: inline-block; margin-right: 10px; font-size: 13px; font-weight: 800; }
.notice-bad { border-left-color: var(--bad); }
.notice-bad .notice-mark { background: var(--bad); }
.notice-bad strong { color: var(--bad); }
.notice-warn { border-left-color: var(--warn); }
.notice-warn .notice-mark { background: var(--warn); }
.notice-warn strong { color: var(--warn); }
.notice-good { border-left-color: var(--good); }
.notice-good .notice-mark { background: var(--good); border-radius: 50%; }
.notice-good strong { color: var(--good); }
.jump { min-height: 44px; padding: 0 12px; border: 0; border-bottom: 2px solid var(--ink); background: none; font-size: 14px; font-weight: 700; white-space: nowrap; }
.jump:hover { background: var(--ground); }
.calm { padding: 14px 0; color: var(--sub); }

/* グラフ */
.chart-block { background: var(--paper); padding: 18px 20px 14px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; color: var(--sub); }
.key { display: inline-block; flex: none; }
.key-bar { width: 12px; height: 12px; background: var(--caramel); }
.key-line { width: 22px; height: 0; border-top: 2px dashed var(--ink); margin-left: 12px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--ink); stroke-width: 1.5; }
.chart .tick { font-family: var(--body); font-size: 12px; fill: var(--sub); }
.chart .bar { fill: var(--caramel); }
.chart .bar-weekend { fill: var(--weekend); }
.chart .prev-line { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-dasharray: 5 4; stroke-linejoin: round; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover, .chart .hit:focus { fill: rgba(54, 38, 28, 0.08); outline: none; }
.chart .hit:focus-visible { stroke: var(--ink); stroke-width: 2; }
.chart-read { margin-top: 6px; font-size: 14px; color: var(--sub); min-height: 1.7em; }

.tip { position: absolute; z-index: 20; padding: 8px 12px; background: var(--ink); color: #fff; font-size: 13px; line-height: 1.6; pointer-events: none; white-space: nowrap; }
.tip-main { font-size: 18px; font-weight: 800; }
.tip-prev { color: #f3dcb6; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; }
.week li { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.week-value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.week-bar { display: flex; align-items: flex-end; width: 100%; max-width: 64px; height: 96px; background: #eef3f4; }
.week-fill { display: block; width: 100%; background: var(--caramel); }
.is-weekend .week-fill { background: var(--weekend); }
.week-label { font-size: 15px; font-weight: 700; }

/* ---------- 商品ごとの表 ---------- */

.table-block { margin-top: 44px; }
.button { min-height: 46px; padding: 0 18px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); font-size: 15px; font-weight: 700; }
.button:hover { background: var(--ink); color: #fff; }
.tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 16px; border: 2px solid var(--ink); border-radius: 999px; background: none; font-size: 15px; font-weight: 700; }
.chip-n { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--paper); font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip[aria-pressed="true"] .chip-n { color: var(--ink); }
.chip-out .chip-n { background: var(--bad-soft); color: var(--bad); }
.chip-soon .chip-n { background: var(--warn-soft); color: var(--warn); }
.field { display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-weight: 700; color: var(--sub); }
.field input, .field select { min-height: 46px; min-width: 170px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); font-size: 16px; font-weight: 400; }
.count { margin: 12px 0 6px; font-size: 14px; color: var(--sub); min-height: 1.7em; }

.ptable { background: var(--paper); border-top: 3px solid var(--ink); }
.prow {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 64px minmax(150px, 1.1fr) 62px 150px 64px minmax(170px, 1fr);
  align-items: center; gap: 0 14px; padding: 9px 16px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.phead { font-size: 13px; font-weight: 700; color: var(--sub); padding-top: 8px; padding-bottom: 8px; background: #f4f8f8; }
.c-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pname { display: block; font-weight: 700; line-height: 1.5; }
.pmeta { display: block; font-size: 12px; color: var(--sub); line-height: 1.5; }
.c-sales { position: relative; display: flex; align-items: center; justify-content: flex-end; min-height: 34px; }
.phead .c-sales { justify-content: flex-end; min-height: 0; }
.sbar { position: absolute; left: 0; top: 4px; bottom: 4px; background: var(--caramel-pale); }
.svalue { position: relative; font-weight: 800; font-variant-numeric: tabular-nums; padding-right: 6px; }
.c-diff { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.diff-yen { font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; padding-left: 8px; }
.c-left { display: flex; flex-direction: column; align-items: flex-start; }
.left-note { font-size: 12px; color: var(--sub); line-height: 1.5; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; line-height: 1.6; }
.tag i { display: inline-grid; place-items: center; width: 20px; height: 20px; font-style: normal; font-size: 12px; color: #fff; background: var(--sub); }
.tag-out { color: var(--bad); }
.tag-out i { background: var(--bad); }
.tag-soon { color: var(--warn); }
.tag-soon i { background: var(--warn); }
.tag-ok { color: var(--good); }
.tag-ok i { background: none; color: var(--good); border: 2px solid var(--good); border-radius: 50%; font-size: 10px; }
.tag-still, .tag-unknown, .tag-none { color: var(--sub); font-weight: 500; }
.prow.is-out { box-shadow: inset 6px 0 0 var(--bad); }
.prow.is-soon { box-shadow: inset 6px 0 0 var(--warn); }
.prow.is-flash { background: var(--warn-soft); }

/* ---------- 数字の決まり ---------- */

.rules { margin: 44px 0 56px; }
.rules dl { margin-top: 10px; border-top: 3px solid var(--ink); }
.rules div { display: grid; grid-template-columns: 9em minmax(0, 1fr); gap: 4px 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rules dt { font-weight: 800; font-size: 15px; }
.rules dd { font-size: 15px; max-width: 52em; }

.foot { background: var(--ink); color: #e3d8cf; padding: 20px 0; font-size: 14px; }

/* ---------- せまい画面 ---------- */

@media (max-width: 960px) {
  .deck { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .receipt { position: static; max-width: 420px; }
  .prow { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 14px; }
  .phead { display: none; }
  .c-name, .c-sales, .c-diff, .c-left { grid-column: 1 / -1; }
  .c-name { order: 0; }
  .c-sales { order: 1; min-height: 34px; }
  .prow > .c-num { order: 2; display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.4; font-weight: 700; }
  .c-diff { order: 3; }
  .c-left { order: 4; }
  .prow > [data-label]::before { content: attr(data-label); font-size: 12px; font-weight: 700; color: var(--sub); white-space: nowrap; }
  .c-sales::before { position: relative; margin-right: auto; padding-left: 8px; }
  .c-diff, .c-left { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
  .c-diff::before, .c-left::before { min-width: 7.5em; }
  .diff-yen { padding-left: 0; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .top h1 { font-size: 22px; }
  .top-sub { display: block; margin: 0; font-size: 14px; }
  .period-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .period-buttons button { padding: 0 6px; font-size: 15px; }
  .receipt { max-width: none; }
  .chart-block { padding: 14px 12px 12px; margin: 0 -16px; }
  .notice { grid-template-columns: 30px minmax(0, 1fr); }
  .jump { grid-column: 2; justify-self: start; padding-left: 0; }
  .week { gap: 6px; }
  .week-value { font-size: 12px; }
  .chips { margin-right: 0; }
  .field { flex: 1 1 140px; }
  .field input, .field select { min-width: 0; width: 100%; }
  .button { width: 100%; }
  .ptable { margin: 0 -16px; }
  .rules div { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
