/* EC在庫の同期
   倉庫の床(濃い緑)に棚の箱(黄)を置き、店は色と形(丸・三角・四角)で見分ける。 */

:root {
  --paper: #eef0ea;
  --white: #ffffff;
  --ink: #18241f;
  --sub: #4a5a53;
  --line: #c9d0c8;
  --floor: #16231e;
  --floor-2: #223329;
  --floor-line: #3a4f45;
  --crate: #f4c531;
  --crate-deep: #b98c00;
  --s0: #2b4c9b;
  --s1: #b8431a;
  --s2: #1b6e53;
  --s3: #6b3fa0;
  --d0: #9db8ff;
  --d1: #ffa57a;
  --d2: #74d8b4;
  --d3: #cbaaf2;
  --red: #b3261e;
  --red-soft: #fde9e6;
  --amber: #8a4f00;
  --amber-soft: #fff0d2;
  --green: #1b6e53;
  --body: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --digit: "Barlow Condensed", "Zen Kaku Gothic New", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  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; }
button:disabled { cursor: not-allowed; }

:focus-visible { outline: 3px solid var(--s0); outline-offset: 2px; }
.floor :focus-visible { outline-color: var(--crate); }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }

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

.top { background: var(--floor); color: var(--white); }
.top-in {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
  padding-top: 18px;
  padding-bottom: 14px;
}
.top h1 { font-size: 26px; line-height: 1.3; font-weight: 700; letter-spacing: 0.02em; }
.top-state { display: flex; flex-wrap: wrap; gap: 2px 18px; font-size: 14px; color: #cfd8d2; }
.top-mode { color: var(--crate); font-weight: 700; }

.notice {
  margin: 0;
  background: var(--crate);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  padding: 8px 0;
}
.notice .wrap { display: block; }

.alert-line, .plain-line {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--red-soft);
  border-left: 6px solid var(--red);
  font-weight: 500;
}
.plain-line { background: var(--white); border-left-color: var(--ink); }

/* ---------- ためす(倉庫の床) ---------- */

.floor {
  background: var(--floor);
  color: var(--white);
  padding: 30px 0 36px;
  border-top: 1px solid var(--floor-line);
}
.floor-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }
.floor-head h2 { font-size: 30px; line-height: 1.35; font-weight: 700; }
.floor-lead { max-width: 40em; margin-top: 8px; font-size: 15px; color: #cfd8d2; }

.mode { display: inline-flex; border: 2px solid var(--white); border-radius: 999px; padding: 3px; flex: none; }
.mode button {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
}
.mode button[aria-pressed="true"] { background: var(--white); color: var(--floor); }

.pick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 26px; }
.pick label { font-size: 14px; color: #cfd8d2; }
.pick select {
  min-height: 48px;
  min-width: 0;
  flex: 1 1 260px;
  max-width: 460px;
  padding: 0 12px;
  border: 2px solid var(--floor-line);
  border-radius: 4px;
  background: var(--floor-2);
  color: var(--white);
  font-size: 16px;
}

.ghost {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid var(--floor-line);
  background: none;
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
}
.ghost:hover { border-bottom-color: var(--crate); }
.ghost:disabled { color: #7d8f86; border-bottom-style: dotted; }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  margin-top: 18px;
}
.stage > * { min-width: 0; }

.counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.counter {
  display: flex;
  flex-direction: column;
  padding: 16px 16px 16px;
  background: var(--floor-2);
  border-top: 6px solid var(--floor-line);
}
.counter:nth-child(1) { border-top-color: var(--d0); }
.counter:nth-child(2) { border-top-color: var(--d1); }
.counter:nth-child(3) { border-top-color: var(--d2); }
.counter:nth-child(4) { border-top-color: var(--d3); }
.counter .store { font-size: 15px; font-weight: 700; }
.counter-num {
  margin-top: 6px;
  font-family: var(--digit);
  font-size: 84px;
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.counter-note { min-height: 3.2em; margin-top: 6px; font-size: 14px; line-height: 1.6; color: #cfd8d2; }
.counter.is-moved .counter-num { color: var(--crate); }
.counter.is-moved .counter-note { color: var(--crate); font-weight: 700; }
.counter.is-unlinked .counter-num { color: #7d8f86; }

.sell {
  min-height: 48px;
  margin-top: auto;
  border: 2px solid var(--white);
  border-radius: 4px;
  background: none;
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
}
.sell:hover:not(:disabled) { background: var(--white); color: var(--floor); }
.sell:active:not(:disabled) { transform: translateY(1px); }
.sell:disabled { border-color: var(--floor-line); color: #8d9e95; }

.shelf {
  position: relative;
  padding: 16px;
  background: #0e1814;
  border: 2px solid var(--crate);
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: start;
  gap: 4px 12px;
}
.shelf-label { font-size: 15px; font-weight: 700; color: var(--crate); }
.shelf-label small { display: block; font-size: 13px; font-weight: 400; color: #cfd8d2; }
.shelf-num {
  font-family: var(--digit);
  font-size: 84px;
  line-height: 0.9;
  font-weight: 600;
  color: var(--crate);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.crates {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap-reverse;
  align-content: flex-start;
  gap: 4px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 3px solid var(--floor-line);
  min-height: 60px;
}
.crate {
  width: 20px;
  height: 16px;
  background: var(--crate);
  box-shadow: inset 0 -4px 0 var(--crate-deep);
}
.crate-more, .crate-none { font-size: 13px; color: #cfd8d2; align-self: center; }
.shelf.is-empty { border-color: var(--d1); }
.shelf.is-empty .shelf-num, .shelf.is-empty .shelf-label { color: var(--d1); }

.run { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 20px; }
.go {
  min-height: 56px;
  padding: 0 30px;
  border: 0;
  border-radius: 4px;
  background: var(--crate);
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 4px 0 var(--crate-deep);
}
.go:hover { background: #ffd54a; }
.go:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--crate-deep); }
.clock { font-size: 14px; color: #cfd8d2; margin-right: auto; }

.result {
  margin-top: 20px;
  padding: 16px 18px;
  background: var(--white);
  color: var(--ink);
  font-size: 15px;
}
.result-idle { color: var(--sub); }
.result-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.result-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.result-list b { font-family: var(--digit); font-size: 24px; line-height: 1.2; font-weight: 600; }
.result-name { color: var(--sub); font-size: 14px; }
.result-note { margin-top: 10px; padding: 10px 12px; background: var(--amber-soft); color: var(--amber); font-weight: 500; }
.result-over { margin-top: 12px; padding: 14px 16px; background: var(--red-soft); border-left: 6px solid var(--red); }
.result-over-title { font-weight: 700; color: var(--red); font-size: 17px; }
.result-over-sub { margin-top: 10px; font-size: 13px; color: var(--sub); }
.notify {
  margin: 4px 0 0;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--line);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- 店の印 ---------- */

.store { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.mark { flex: none; width: 12px; height: 12px; background: var(--s0); }
.m0 { border-radius: 50%; background: var(--s0); }
.m1 { background: var(--s1); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.m2 { background: var(--s2); }
.m3 { background: var(--s3); transform: rotate(45deg) scale(0.85); }
.floor .m0 { background: var(--d0); }
.floor .m1 { background: var(--d1); }
.floor .m2 { background: var(--d2); }
.floor .m3 { background: var(--d3); }
.floor .result .m0 { background: var(--s0); }
.floor .result .m1 { background: var(--s1); }
.floor .result .m2 { background: var(--s2); }
.floor .result .m3 { background: var(--s3); }

/* ---------- 本文 ---------- */

.body { padding-top: 28px; padding-bottom: 56px; }
.headline { font-size: 18px; font-weight: 500; line-height: 1.7; max-width: 44em; }

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

h2 { font-size: 23px; line-height: 1.4; font-weight: 700; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-bottom: 12px; }
.hint { max-width: 46em; font-size: 14px; color: var(--sub); margin-bottom: 14px; }
.fine { font-size: 13px; color: var(--sub); margin-top: 10px; }
.empty { padding: 18px 0; color: var(--sub); border-top: 2px solid var(--ink); }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: none;
  font-size: 14px;
  font-weight: 500;
}
.tab-n { font-family: var(--digit); font-size: 17px; font-weight: 600; }
.tab[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.tab:hover:not([aria-pressed="true"]) { background: var(--white); }

/* 在庫の表 */
.stock-table { border-top: 2px solid var(--ink); background: var(--white); }
.srow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(var(--stores, 3), 80px) 80px 160px;
  align-items: center;
  gap: 0 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
}
.shead { background: var(--paper); font-size: 13px; font-weight: 700; line-height: 1.4; padding-top: 10px; padding-bottom: 10px; }
.shead .c-q { display: flex; justify-content: flex-end; text-align: right; }
.shead .store { flex-direction: column; align-items: flex-end; gap: 4px; }
.srow.is-current { box-shadow: inset 6px 0 0 var(--crate); }
.c-name { min-width: 0; }
.pname { display: block; font-size: 15px; font-weight: 500; line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; }
.sku { font-family: var(--digit); font-size: 15px; font-weight: 500; letter-spacing: 0.03em; color: var(--sub); }
.c-q { text-align: right; }
.q-label { display: none; }
.q { font-family: var(--digit); font-size: 26px; line-height: 1.2; font-weight: 500; font-variant-numeric: tabular-nums; }
.c-shared .q { font-weight: 600; }
.srow:not(.shead) .c-shared { background: #fff6d6; margin: -9px 0; padding: 9px 8px; align-self: stretch; display: flex; align-items: center; justify-content: flex-end; }
.q-diff { background: var(--amber-soft); color: var(--amber); padding: 0 6px; box-shadow: inset 0 -3px 0 var(--amber); }
.q-none { font-family: var(--body); font-size: 13px; font-weight: 500; color: var(--sub); border: 1px dashed var(--sub); padding: 2px 6px; }
.c-note { padding-left: 6px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; line-height: 1.4; }
.badge i {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-style: normal;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
}
.badge-ok { color: var(--green); }
.badge-out { color: var(--sub); }
.badge-out i { background: var(--sub); }
.badge-pending { color: var(--amber); }
.badge-pending i { background: var(--amber); border-radius: 0; }
.badge-over { color: var(--red); }
.badge-over i { background: var(--red); border-radius: 0; }
.badge-unlinked { color: var(--ink); }
.badge-unlinked i { background: none; color: var(--ink); border: 1px dashed var(--ink); border-radius: 0; }

/* 店と決まり */
.side section + section { margin-top: 34px; }
.side h2 { font-size: 20px; margin-bottom: 10px; }
.stores li { padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.6; }
.stores li:first-child { border-top: 2px solid var(--ink); }
.stores-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 16px; font-weight: 700; }
.stores-ok { color: var(--green); font-weight: 500; }
.stores-ok i { font-style: normal; margin-right: 4px; }
.stores-miss { color: var(--ink); }
.stores-last { color: var(--sub); }

.tag { display: inline-block; padding: 1px 8px; font-size: 12px; font-weight: 700; line-height: 1.6; border: 1px solid var(--ink); white-space: nowrap; }
.tag-demo { border-color: var(--crate-deep); background: #fff6d6; color: #5c4500; }
.tag-plan { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }

.rules { border-top: 2px solid var(--ink); }
.rules dt { padding-top: 10px; font-size: 13px; font-weight: 700; color: var(--sub); }
.rules dd { padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.7; }

/* 出来事 */
.events, .history { margin-top: 48px; }
.alerts li {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) auto;
  gap: 6px 20px;
  align-items: start;
  padding: 14px 16px;
  background: var(--red-soft);
  border-left: 6px solid var(--red);
  font-size: 15px;
}
.alerts li + li { margin-top: 8px; }
.akind { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--red); }
.akind i { display: inline-grid; place-items: center; width: 22px; height: 22px; background: var(--red); color: var(--white); font-style: normal; font-size: 14px; }
.atitle { font-weight: 700; }
.atitle .sku { margin-left: 10px; }
.atime { font-size: 14px; color: var(--sub); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }

/* 履歴 */
.save {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.save:hover { background: var(--ink); color: var(--white); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; }
.field { display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-weight: 700; color: var(--sub); }
.field.grow { flex: 1 1 220px; max-width: 340px; }
.field select, .field input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  width: 100%;
}
.count { margin: 14px 0 6px; font-size: 14px; color: var(--sub); min-height: 1.7em; }

.log { border-top: 2px solid var(--ink); background: var(--white); }
.lrow {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 170px 150px 200px;
  align-items: center;
  gap: 0 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.lrow.is-demo { background: #fffbea; }
.lrow.is-planned { background: var(--amber-soft); }
.l-time { color: var(--sub); font-variant-numeric: tabular-nums; }
.l-name { min-width: 0; }
.l-name .pname { font-size: 14px; }
.l-change { display: inline-flex; align-items: baseline; gap: 6px; font-family: var(--digit); font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.l-change .from { color: var(--sub); }
.l-change .arrow { font-family: var(--body); font-size: 13px; color: var(--sub); }
.l-change b { font-weight: 600; }
.delta { font-size: 16px; font-weight: 600; margin-left: 4px; }
.delta.down { color: var(--s1); }
.delta.up { color: var(--green); }
.l-why { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.kind { font-size: 13px; font-weight: 700; padding-left: 8px; border-left: 4px solid var(--sub); line-height: 1.5; }
.kind-sold { border-left-color: var(--s1); }
.kind-added { border-left-color: var(--green); }
.kind-first { border-left-color: var(--s0); }

.more {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: none;
  font-size: 15px;
  font-weight: 700;
}
.more:hover { background: var(--white); }

.foot { background: var(--floor); color: #cfd8d2; padding: 22px 0; font-size: 14px; }

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

@media (max-width: 980px) {
  .cols { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .stage { grid-template-columns: minmax(0, 1fr); }
  .shelf { grid-template-columns: 1fr auto; }
  .lrow { grid-template-columns: 88px minmax(0, 1fr) 150px 140px; }
  .l-why { grid-column: 2 / -1; padding-bottom: 2px; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .top h1 { font-size: 24px; }
  .floor { padding: 24px 0 28px; }
  .floor-head h2 { font-size: 24px; }
  .mode { width: 100%; }
  .mode button { flex: 1; padding: 0 8px; }
  .pick select { flex-basis: 100%; max-width: none; }

  .counters { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .counter {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 112px;
    grid-template-areas: "name num sell" "note note sell";
    align-items: center;
    gap: 0 12px;
    padding: 10px 12px;
    border-top: 0;
    border-left: 6px solid var(--floor-line);
  }
  .counter:nth-child(1) { border-left-color: var(--d0); }
  .counter:nth-child(2) { border-left-color: var(--d1); }
  .counter:nth-child(3) { border-left-color: var(--d2); }
  .counter:nth-child(4) { border-left-color: var(--d3); }
  .counter .store { grid-area: name; font-size: 14px; line-height: 1.4; }
  .counter-num { grid-area: num; margin: 0; font-size: 52px; }
  .counter-note { grid-area: note; min-height: 0; margin: 0; font-size: 13px; }
  .counter.is-unlinked .counter-note { grid-column: 1 / -1; }
  .sell { grid-area: sell; margin: 0; font-size: 15px; min-height: 52px; }

  .shelf-num, .counter-num { line-height: 1; }
  .shelf-num { font-size: 60px; }
  .crate { width: 16px; height: 13px; }
  .run { gap: 8px 16px; }
  .go { width: 100%; }
  .clock { flex-basis: 100%; }

  .headline { font-size: 16px; }
  h2 { font-size: 22px; }

  .shead { display: none; }
  .srow {
    grid-template-columns: repeat(calc(var(--stores, 3) + 1), minmax(0, 1fr));
    gap: 8px 6px;
    padding: 12px 12px 12px;
  }
  .c-name { grid-column: 1 / span 2; }
  .c-note { grid-column: 3 / -1; grid-row: 1; padding: 0; justify-self: end; align-self: start; text-align: right; }
  .c-q { text-align: left; display: flex; flex-direction: column; gap: 2px; }
  .q-label { display: block; font-size: 12px; line-height: 1.35; color: var(--sub); min-height: 2.7em; }
  .q-label .store { align-items: flex-start; gap: 4px; }
  .q-label .mark { width: 9px; height: 9px; margin-top: 4px; }
  .srow:not(.shead) .c-shared { margin: 0; padding: 4px 6px; flex-direction: column; align-items: flex-start; justify-content: flex-start; }
  .q { font-size: 24px; }
  .q-none { align-self: flex-start; font-size: 12px; }

  .alerts li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .atime { flex-direction: row; align-items: center; gap: 10px; }

  .filters { gap: 10px 12px; }
  .field { flex: 1 1 140px; }
  .field.grow { max-width: none; flex-basis: 100%; }
  .save { width: 100%; justify-content: center; }

  .lrow {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name name" "store time" "change why";
    gap: 4px 10px;
    padding: 10px 12px;
  }
  .l-time { grid-area: time; text-align: right; font-size: 13px; }
  .l-name { grid-area: name; }
  .l-store { grid-area: store; }
  .l-change { grid-area: change; }
  .l-why { grid-area: why; grid-column: auto; justify-content: flex-end; }
}

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