/* 在庫切れ・入荷アラートの画面。
   見た目の題材は、倉庫の棚札と表示灯(黒と黄の縞、緑・橙・赤の灯り)。
   文字の大きさ・行の高さ・ボタンの高さは、実在の在庫表示・在庫管理サービス10件を測った範囲に合わせている
   (本文14px、行間1.4〜1.5、状態の文字11〜18px、表の行36〜61px、ボタン30〜48px、白地)。 */
:root {
  --ink: #1b1b1b;
  --muted: #5f6368;
  --line: #dcdfe3;
  --paper: #ffffff;
  --shade: #f2f3f5;
  --caution: #ffcc00;    /* 注意の黄 */
  --ok: #1e7a3c;         /* 在庫あり */
  --ok-pale: #e6f3ea;
  --low: #b85c00;        /* 残りわずか */
  --low-pale: #fff0dc;
  --out: #c2271e;        /* 在庫切れ */
  --out-pale: #fde9e7;
  --num: "Oswald", "M PLUS 1p", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "M PLUS 1p", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--caution); outline-offset: 2px; box-shadow: 0 0 0 5px var(--ink); }

.wrap { width: min(100% - 2rem, 68rem); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- 題字の板:黒い板と、黄と黒の縞 ---------- */
.plate {
  background: var(--ink);
  color: #fff;
  border-bottom: 0.6rem solid transparent;
  border-image: repeating-linear-gradient(-45deg, var(--caution) 0 0.7rem, var(--ink) 0.7rem 1.4rem) 12;
}
.plate-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; padding: 0.9rem 0 0.8rem; }
.plate h1 { font-size: 1.25rem; font-weight: 900; letter-spacing: 0.04em; }
.plate .updated { color: #c9cdd2; font-size: 0.8125rem; }

main.wrap { padding: 1rem 0 2.5rem; }

.banner {
  margin-bottom: 1rem;
  padding: 0.55rem 0.9rem;
  border-left: 0.3rem solid var(--caution);
  background: #fff8d6;
  font-size: 0.8125rem;
}
.banner-warn { border-left-color: var(--out); background: var(--out-pale); }

/* ---------- 見回りのデモ ---------- */
.patrol {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin-bottom: 1rem;
  padding: 0.7rem 0.9rem;
  background: var(--ink);
  color: #fff;
}
.patrol-lamp { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: #555; }
.patrol-lamp.is-on { background: var(--caution); animation: blink 0.9s steps(2) infinite; }
.patrol-lamp.is-done { background: #46c36f; }
@keyframes blink { 50% { opacity: 0.25; } }
.patrol-text { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.patrol-button {
  height: 2.25rem;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 2px;
  background: var(--caution);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.patrol-button:disabled { opacity: 0.5; cursor: wait; }
.patrol-note { grid-column: 1 / -1; font-size: 0.75rem; color: #c9cdd2; }

/* ---------- さがす・しぼる・並べる ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.search { flex: 1 1 13rem; }
.search input {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.8rem;
  border: 1px solid var(--muted);
  border-radius: 2px;
  background: #fff;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
}
.chip-out { border-bottom-color: var(--out); }
.chip-low { border-bottom-color: var(--low); }
.chip-ok { border-bottom-color: var(--ok); }
.chip-count { margin-left: 0.4rem; font-family: var(--num); font-weight: 600; font-size: 1rem; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.chip-out[aria-pressed="true"] { border-bottom-color: var(--out); }
.chip-low[aria-pressed="true"] { border-bottom-color: #ff9a2e; }
.chip-ok[aria-pressed="true"] { border-bottom-color: #46c36f; }
.sort { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.sort select { height: 2.5rem; padding: 0 0.5rem; border: 1px solid var(--line); border-radius: 2px; background: #fff; }
.button {
  display: inline-flex;
  align-items: center;
  height: 2.25rem;
  padding: 0 0.8rem;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.button:hover { background: var(--shade); }

/* ---------- 一覧 ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
.split > *, .row-item { min-width: 0; }

.list-head, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6.5rem 7.5rem 6rem;
  gap: 0.75rem;
  align-items: center;
}
.list-head { padding: 0.35rem 0.75rem 0.35rem 1rem; border-bottom: 2px solid var(--ink); font-size: 0.75rem; color: var(--muted); }

/* 棚札:左の太い帯の色が、その商品の状態 */
.row-item { border-bottom: 1px solid var(--line); border-left: 0.35rem solid var(--ok); }
.row-item.is-low { border-left-color: var(--low); }
.row-item.is-out { border-left-color: var(--out); }
.row {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.35rem 0.75rem 0.35rem 0.65rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.row:hover { background: var(--shade); }
/* 急ぐ商品ほど、大きく見せる。在庫ありは1行に畳む */
.is-low > .row { min-height: 3.5rem; background: var(--low-pale); }
.is-out > .row { min-height: 3.75rem; background: var(--out-pale); }
.is-open > .row { box-shadow: inset 0 -2px 0 var(--ink); }
.row.is-checking { outline: 3px solid var(--caution); outline-offset: -3px; }
.row.is-changed { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: inset 0 0 0 4px var(--caution); } to { box-shadow: inset 0 0 0 0 transparent; } }

.row-name { display: grid; min-width: 0; }
.row-title { font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.row-shop { font-size: 0.75rem; color: var(--muted); }
.is-ok .row-shop { display: none; }
.is-low .row-title, .is-out .row-title { font-size: 0.9375rem; }

.level { font-weight: 700; font-size: 0.8125rem; white-space: nowrap; }
.level-mark { margin-right: 0.3rem; font-size: 0.75em; }
.level-ok { color: var(--ok); }
.level-low { color: var(--low); }
.level-out { color: var(--out); }
.is-low .level, .is-out .level { font-size: 0.9375rem; }

.qty { white-space: nowrap; }
.qty b { font-family: var(--num); font-weight: 600; font-size: 1.125rem; margin-right: 0.1rem; }
.is-low .qty b, .is-out .qty b { font-size: 1.5rem; }
.qty small { display: block; font-size: 0.75rem; color: var(--muted); }
.is-ok .qty small { display: inline; margin-left: 0.4rem; }
.qty-none { font-size: 0.75rem; color: var(--muted); }
.since { font-size: 0.8125rem; white-space: nowrap; }
.since small { display: block; font-size: 0.75rem; color: var(--muted); }
.is-ok .since small { display: none; }

.empty { padding: 1.25rem 0.75rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: 0.9rem; font-size: 0.75rem; color: var(--muted); }

/* ---------- 開いた商品の中身 ---------- */
.detail { padding: 0.9rem 0.9rem 1.1rem 0.65rem; background: #fff; }
.period { display: inline-flex; border: 1px solid var(--ink); border-radius: 2px; }
.period button { height: 1.9rem; padding: 0 0.8rem; border: 0; border-left: 1px solid var(--ink); background: #fff; font-size: 0.8125rem; cursor: pointer; }
.period button:first-child { border-left: 0; }
.period button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 700; }

.strip { display: flex; height: 1.1rem; margin-top: 0.75rem; background: var(--shade); overflow: hidden; }
.seg { height: 100%; min-width: 1px; }
.seg-ok { background: var(--ok); }
.seg-low { background: var(--low); }
/* 在庫切れは、色に加えて縞でも見分けられるようにする */
.seg-out { background: repeating-linear-gradient(-45deg, var(--out) 0 4px, #7d1812 4px 8px); }
.strip-ends { display: flex; justify-content: space-between; margin-top: 0.2rem; font-size: 0.75rem; color: var(--muted); }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 0.75rem; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.facts div { padding: 0.45rem 0.6rem; border-left: 1px solid var(--line); }
.facts div:first-child { border-left: 0; padding-left: 0; }
.facts dt { font-size: 0.75rem; color: var(--muted); }
.facts dd { font-weight: 700; }

.chart-box { position: relative; height: 11rem; margin-top: 0.75rem; }
.detail-note { margin-top: 0.35rem; font-size: 0.75rem; color: var(--muted); }

.demo { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px dashed var(--muted); }
.demo-title { width: 100%; font-weight: 700; font-size: 0.8125rem; }
.demo .detail-note { width: 100%; }
.demo-button {
  height: 2.5rem;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 2px;
  background: var(--caution);
  font-weight: 700;
  cursor: pointer;
}
.demo-button:hover { background: #ffd83d; }
.detail-link { display: inline-block; margin-top: 0.75rem; color: #0b57d0; }

/* ---------- 通知の決まりと、最近の出来事 ---------- */
.side h2 { font-size: 1rem; font-weight: 900; }
.rules { padding: 0.9rem 1rem; background: var(--shade); border-top: 0.3rem solid var(--ink); }
.rules dl { margin-top: 0.5rem; }
.rules dl div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.75rem; padding: 0.4rem 0; border-top: 1px solid var(--line); }
.rules dt { font-size: 0.75rem; color: var(--muted); padding-top: 0.1rem; }
.rules-note { margin-top: 0.5rem; font-size: 0.75rem; color: var(--muted); }

.events { margin-top: 1.5rem; }
.events-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding-bottom: 0.4rem; border-bottom: 2px solid var(--ink); }
.event {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  grid-template-areas: "when kind change" "when name name";
  gap: 0 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.event-when { grid-area: when; font-size: 0.75rem; color: var(--muted); padding-top: 0.15rem; }
.event-kind { grid-area: kind; font-weight: 700; }
.event-out .event-kind { color: var(--out); }
.event-low .event-kind { color: var(--low); }
.event-ok .event-kind { color: var(--ok); }
.event-change { grid-area: change; font-family: var(--num); font-size: 0.875rem; white-space: nowrap; }
.event-name { grid-area: name; font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.event.is-demo { background: #fff8d6; }
.event.is-demo .event-name::after { content: "(デモ)"; margin-left: 0.3rem; }
.more { margin-top: 0.6rem; height: 2.25rem; padding: 0 0.8rem; border: 1px solid var(--line); border-radius: 2px; background: #fff; font-size: 0.8125rem; cursor: pointer; }

/* ---------- 通知の見本(右下に出る) ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 20; display: grid; gap: 0.5rem; width: min(24rem, calc(100% - 2rem)); }
.toast { padding: 0.7rem 0.9rem; background: var(--ink); color: #fff; border-left: 0.35rem solid var(--caution); font-size: 0.8125rem; overflow-wrap: anywhere; }
.toast strong { display: block; margin-bottom: 0.15rem; font-size: 0.75rem; color: var(--caution); }
.toast.is-quiet { background: #44474b; border-left-color: #8a8f95; }
.toast.is-quiet strong { color: #fff; }

.site-footer { background: var(--ink); color: #c9cdd2; padding: 1.25rem 0; font-size: 0.8125rem; }
.site-footer a { color: #fff; }

/* ---------- 広い画面:左に一覧、右に決まりと出来事 ---------- */
@media (min-width: 60rem) {
  .split { grid-template-columns: minmax(0, 13fr) minmax(0, 7fr); align-items: start; }
}

/* ---------- 狭い画面:行を2段にする ---------- */
@media (max-width: 40rem) {
  .list-head { display: none; }
  .rows { border-top: 2px solid var(--ink); }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name level" "qty since";
    gap: 0.15rem 0.75rem;
    padding: 0.5rem 0.6rem 0.5rem 0.55rem;
  }
  .row-name { grid-area: name; }
  .level { grid-area: level; justify-self: end; }
  .qty { grid-area: qty; }
  .since { grid-area: since; justify-self: end; text-align: right; }
  .is-ok .qty small { display: none; }
  .since small { display: inline; margin-left: 0.35rem; }
  .is-ok .since small { display: none; }
  .facts { grid-template-columns: 1fr; }
  .facts div, .facts div:first-child { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-left: 0; border-top: 1px solid var(--line); }
  .facts div:first-child { border-top: 0; }
  .patrol { grid-template-columns: auto 1fr; }
  .patrol-button { grid-column: 1 / -1; }
  .sort { flex: 1; }
  .sort select { flex: 1; min-width: 0; }
  .rules dl div { grid-template-columns: 6.5rem 1fr; }
  .demo-button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .patrol-lamp.is-on, .row.is-changed { animation: none; }
}

/* スマートフォンでは、押す部品・入力欄の高さを44px以上にそろえる */
@media (max-width: 48rem) {
  button, select, a.button,
  input:not([type="radio"]):not([type="checkbox"]):not([type="hidden"]) { min-height: 2.75rem !important; }
}
