:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1c2024;
  --muted: #6b7280;
  --accent: #2f6feb;
  --ok: #1a7f45;
  --ok-bg: #e7f6ec;
  --warn: #9a6200;
  --warn-bg: #fdf3df;
  --err: #b3261e;
  --err-bg: #fdeceb;
  --gone: #7c3aed;
  --gone-bg: #f2ecfe;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --panel: #1c2024;
    --border: #2c3238;
    --text: #e6e9ec;
    --muted: #9aa3ad;
    --accent: #6c9bff;
    --ok: #6fd39a;
    --ok-bg: #16311f;
    --warn: #e8c07d;
    --warn-bg: #3a2f16;
    --err: #ff9b93;
    --err-bg: #3b1c19;
    --gone: #c4a5ff;
    --gone-bg: #2b2140;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Meiryo", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--accent); }

header.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

header.topbar .brand {
  font-weight: 700;
  font-size: 15px;
  padding: 14px 0;
  white-space: nowrap;
}

header.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }

header.topbar nav a {
  padding: 14px 12px;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
header.topbar nav a.active,
header.topbar nav a:hover {
  color: var(--text);
  border-bottom-color: var(--accent);
}

header.topbar .spacer { flex: 1; }

/* 画面上部の「かんたん利益計算」 */
.hcalc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 0; font-size: 13px; }
.hcalc .hcalc-title { font-weight: 700; white-space: nowrap; }
.hcalc select { width: auto; min-width: 104px; padding: 5px 8px; font-size: 13px; }
.hcalc .hcalc-in { display: inline-flex; align-items: center; gap: 3px; margin: 0; }
.hcalc .hcalc-in input { width: 104px; padding: 5px 8px; font-size: 13px; }
.hcalc .hcalc-in em { font-style: normal; color: var(--muted); font-size: 12px; min-width: 26px; }
.hcalc .hcalc-out { font-weight: 700; white-space: nowrap; }
.hcalc .hcalc-out.pos { color: var(--ok); }
.hcalc .hcalc-out.neg { color: var(--err); }
.hcalc .hcalc-out.muted { font-weight: 400; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 64px; }

.banner {
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 16px;
  border: 1px solid;
}
.banner.dry { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.banner.info { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 2px; }

section.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 18px 20px;
  margin-bottom: 20px;
}
section.panel > h2 {
  margin: 0 0 4px;
  font-size: 15px;
}
section.panel > p.hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:hover { background: rgba(127, 127, 127, 0.05); }

.table-wrap { overflow-x: auto; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.err { background: var(--err-bg); color: var(--err); }
.tag.gone { background: var(--gone-bg); color: var(--gone); }
.tag.muted { background: rgba(127,127,127,.14); color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td .truncate { max-width: 230px; }

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover, .btn.primary:hover { opacity: .88; color: #fff; }
button.danger { color: var(--err); }
button:disabled { opacity: .5; cursor: default; }

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
/* 各操作を <form> で包んでいるので、ボタンを直接の flex アイテムとして扱う */
.btn-row form { display: contents; }
.btn-row input[type=text] { width: auto; }

/* テーブル内の操作ボタンは小さめにして、1〜2行に収める */
td .btn-row { min-width: 178px; }
td .btn-row button { padding: 3px 8px; font-size: 12px; }
td .btn-row input[type=text] { padding: 3px 8px; font-size: 12px; width: 104px; }

input[type=text], input[type=password], input[type=number], textarea, select {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
}
textarea { min-height: 110px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

.login-wrap {
  max-width: 340px;
  margin: 12vh auto;
}

.result-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  white-space: pre-wrap;
}

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 12px; }
dl.kv dd { margin: 0; }

/* ---------------------------------------------------------------- 商品カード */
.cardlist { display: flex; flex-direction: column; gap: 10px; }

.itemcard {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
@media (max-width: 720px) {
  .itemcard { grid-template-columns: 60px 1fr; }
  .itemcard .itemactions { grid-column: 1 / -1; }
}

.itemcard .thumb {
  width: 76px; height: 76px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(127,127,127,.12);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.itemcard .thumb img { width: 100%; height: 100%; object-fit: cover; }
.noimg { font-size: 11px; color: var(--muted); text-align: center; }

.itembody { min-width: 0; }
.itemtitle {
  display: block;
  font-weight: 600;
  margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.itemactions { display: flex; flex-direction: column; gap: 6px; }
.itemactions .btn, .itemactions button { white-space: nowrap; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; align-items: center; }
a.tag { text-decoration: none; }
a.tag:hover { filter: brightness(1.08); }

/* ---------------------------------------------------------------- 商品詳細 */
.detailhead { display: grid; grid-template-columns: 300px 1fr; gap: 24px; }
@media (max-width: 860px) { .detailhead { grid-template-columns: 1fr; } }

.gallery .mainimg {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(127,127,127,.1);
  display: flex; align-items: center; justify-content: center;
}
.gallery .thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.gallery .thumbs img {
  width: 54px; height: 54px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border);
}
.detailinfo { min-width: 0; }

.switches { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.switch { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.switch input { margin-top: 3px; width: 16px; height: 16px; }

.listingcard {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--bg);
}
.listinghead {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.listinghead strong { margin-right: 6px; }

.calcbox {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 4px;
}

.ratesgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 14px;
  margin-bottom: 8px;
}

/* 一覧カードの長いエラー文で高さが暴れないよう2行までにする */
.itembody .small[style*="--err"], .itembody .small[style*="--warn"] {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------------- 一括操作 */
.itemcard { position: relative; }
.bulkpick {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 2;
  padding: 4px;
  border-radius: 6px;
  background: rgba(127, 127, 127, .14);
  cursor: pointer;
  line-height: 0;
}
.bulkpick input { width: 16px; height: 16px; cursor: pointer; }
.itemcard.picked { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
#bulkbar .btn-row { flex-wrap: wrap; gap: 8px; }


/* --- 一覧の中の、国ごとの操作 ------------------------------------------ */
/* 1件ずつ詳細画面を開かずに、その場でデリスト・再掲載できるようにする */
.countryrows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.countryrow {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.small-btn {
  padding: 2px 10px;
  font-size: 12px;
  line-height: 1.6;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: inherit;
  cursor: pointer;
}
.small-btn:hover { border-color: var(--accent); }
.small-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.small-btn:disabled { opacity: .5; cursor: default; }

/* 押して切り替えられるタグ。見た目はタグのまま、押せることが分かるように */
button.tag {
  border: 1px dashed transparent;
  cursor: pointer;
  font-family: inherit;
}
button.tag:hover { border-color: currentColor; }
button.tag:disabled { opacity: .6; cursor: default; }

/* ---- 注文タブ: 表示の詰め具合 ------------------------------------- */
#orderlist .ord-line { display: none; }
#orderlist .ord-names {
  flex: 1 1 auto; min-width: 60px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#orderlist .ord-profit { flex: 0 0 auto; }

/* 一覧: 1注文1行 */
#orderlist.dens-list .ord-line {
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden;
}
#orderlist.dens-list .ord-full,
#orderlist.dens-list .ord-body,
#orderlist.dens-list .ord-fees { display: none; }
#orderlist.dens-list .listingcard { padding: 5px 10px; margin-bottom: 5px; }
#orderlist.dens-list .listinghead { display: block; margin-bottom: 0; }
#orderlist.dens-list .listingcard.open { padding: 14px; margin-bottom: 14px; }
#orderlist.dens-list .listingcard.open .listinghead {
  display: flex; margin-bottom: 12px;
}
#orderlist.dens-list .listingcard.open .ord-line { display: none; }
#orderlist.dens-list .listingcard.open .ord-full { display: block; }
#orderlist.dens-list .listingcard.open .ord-body { display: block; }
#orderlist.dens-list .listingcard.open .ord-fees { display: block; }

/* 一覧の行頭に出す小さな写真 */
#orderlist .ord-mini { display: none; }
#orderlist.dens-list .ord-mini { display: block; flex: 0 0 26px; }
#orderlist.dens-list .listingcard.open .ord-mini { display: none; }

/* ふつう: 1行目に「商品名・SKU・進捗・保存」、2行目に入力欄。
   「展開」を押した1件(.open)には、この詰め方をかけない = くわしく表示になる */
#orderlist .oi-break { display: none; }

#orderlist.dens-normal .listingcard:not(.open) .ord-extra,
#orderlist.dens-normal .listingcard:not(.open) .ord-fees,
#orderlist.dens-normal .listingcard:not(.open) .oi-dup,
#orderlist.dens-normal .listingcard:not(.open) .oi-stock,
#orderlist.dens-normal .listingcard:not(.open) .oi-src { display: none !important; }
#orderlist.dens-normal .listingcard:not(.open) { padding: 8px 10px; margin-bottom: 8px; }
#orderlist.dens-normal .listingcard:not(.open) .listinghead { margin-bottom: 4px; }
#orderlist.dens-normal .listingcard:not(.open) .ord-img {
  width: 40px !important; height: 40px !important;
}
#orderlist.dens-normal .listingcard:not(.open) .item-edit {
  padding: 5px 0 !important; grid-template-columns: 40px 1fr !important; gap: 8px !important;
}
#orderlist.dens-normal .listingcard:not(.open) .oi-main {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
}
#orderlist.dens-normal .listingcard:not(.open) .oi-main > * { margin: 0 !important; }

/* 並び順: 商品名 → SKU → 進捗と保存 → (改行) → 入力欄 */
#orderlist.dens-normal .listingcard:not(.open) .oi-title { order: 1; flex: 1 1 200px;
  min-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#orderlist.dens-normal .listingcard:not(.open) .oi-sku { order: 2; flex: 0 0 auto; }
#orderlist.dens-normal .listingcard:not(.open) .oi-buy { order: 2; flex: 0 0 auto; }
#orderlist.dens-normal .listingcard:not(.open) .oi-title { min-width: 120px; }
#orderlist.dens-normal .listingcard:not(.open) .oi-checks { order: 3; }
#orderlist.dens-normal .listingcard:not(.open) .oi-break {
  order: 4; display: block; flex: 0 0 100%; height: 0; margin: 0;
}
#orderlist.dens-normal .listingcard:not(.open) .oi-costrow { order: 5; }
#orderlist.dens-normal .listingcard:not(.open) .oi-supplier { order: 6; }
#orderlist.dens-normal .listingcard:not(.open) .oi-memorow { order: 7; }

#orderlist.dens-normal .listingcard:not(.open) .oi-main > .btn-row {
  margin: 0 !important; gap: 6px; flex: 0 0 auto; align-items: center;
}
/* 見出しは隠して、欄の中の薄字(プレースホルダ)で何の欄か示す */
#orderlist.dens-normal .listingcard:not(.open) .oi-main .field { margin-bottom: 0; }
#orderlist.dens-normal .listingcard:not(.open) .oi-main .field > span { display: none; }
#orderlist.dens-normal .listingcard:not(.open) .oi-main input[type=text] {
  padding: 3px 6px; font-size: .86rem;
}
#orderlist.dens-normal .listingcard:not(.open) .oi-date { max-width: 132px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-main input[type=date] {
  padding: 2px 4px; font-size: .82rem;
}
#orderlist.dens-normal .listingcard:not(.open) .oi-cost { max-width: 104px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-f1 { max-width: 118px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-f2 { max-width: 140px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-f3 { max-width: 84px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-memo { max-width: 150px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-memo2 { max-width: 130px !important; }

/* 進捗は、押すと色が変わる札にする。四角のチェックより場所を取らない */
#orderlist.dens-normal .listingcard:not(.open) .oi-checks { gap: 5px; }
#orderlist.dens-normal .listingcard:not(.open) .oi-chk {
  white-space: nowrap; cursor: pointer; user-select: none;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 9px; font-size: .8rem; color: var(--muted);
}
#orderlist.dens-normal .listingcard:not(.open) .oi-chk input[type=checkbox] {
  position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none;
}
#orderlist.dens-normal .listingcard:not(.open) .oi-chk.on {
  background: rgba(16, 185, 129, .16);
  border-color: rgba(16, 185, 129, .55);
  color: var(--text); font-weight: 600;
}

/* クリックするだけのボタンは小さく */
#orderlist .refresh-one,
#orderlist .open-one,
#orderlist.dens-normal .listingcard:not(.open) .oi-checks button[type=submit] {
  padding: 2px 9px !important; font-size: .8rem !important; line-height: 1.6;
}

/* 「展開」ボタンは、くわしく表示のときは要らない */
#orderlist .open-full { display: none; }
#orderlist.dens-normal .open-full { display: inline-block; }

/* 注文タブの操作バー: 中身がはみ出して重ならないようにする */
#savebar { align-items: center; gap: 10px; row-gap: 6px; }
#savebar button { white-space: nowrap; }
#savebar #save-all-note { line-height: 1.5; }

/* 進捗の札の中に、押した日を小さく出す */
#orderlist .oi-when { font-size: .74rem; opacity: .75; margin-left: 3px; }
#orderlist .oi-when:empty { display: none; }

/* 写真を押すと選ぶ/外す。押せることが分かるようにする */
.itemcard .pick-thumb { cursor: pointer; position: relative; }
.itemcard .pick-thumb:hover { outline: 2px solid var(--accent, #2563eb); outline-offset: 1px; }
.itemcard.picked .pick-thumb { outline: 3px solid rgba(37, 99, 235, .8); outline-offset: 1px; }

/* 商品カードの、まるごとの操作 */
.itemcard .cardops { margin: 6px 0 4px; gap: 6px; }

/* ボタンは縮めない。縮むと中の文字が枠からはみ出して、隣に重なる */
.btn-row > button { flex: 0 0 auto; white-space: nowrap; }

/* 仕入先への近道。字だけなので、行の高さは増えない */
#orderlist .oi-buy { white-space: nowrap; }
#orderlist .ord-img { display: block; }

/* 画面のすみに出すお知らせ。OKを押すだけの窓の代わり */
#toastbox {
  position: fixed; right: 16px; bottom: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(440px, calc(100vw - 32px));
}
.toast {
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  font-size: 13px; white-space: pre-wrap; line-height: 1.6;
}
.toast.ok { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.toast.err { border-color: var(--err); background: var(--err-bg); color: var(--err); }

/* 出品・再掲載する国の選択 */
#regionpick { gap: 8px; }
#regionpick .region-chip {
  white-space: nowrap; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); cursor: pointer;
}
#regionpick .region-chip:has(input:checked) {
  background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 600;
}

/* --- 注文タブ: 売れた国の在庫数・販売価格 ---------------------------
   「ふつう」でも出す。そのぶん他の欄を少しずつ詰めて、
   1注文の高さが増えないようにする。                                  */
.oi-listing .tag.warn { margin-left: 4px; }
.oi-listing .ls-note { flex: 1 1 100%; }

#orderlist.dens-normal .listingcard:not(.open) .oi-listing { order: 8; }
#orderlist.dens-normal .listingcard:not(.open) .oi-ls1 { max-width: 64px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-ls2 { max-width: 92px !important; }
/* 「PH の出品」の見出しは、ふつう表示では国名だけの札にする */
#orderlist.dens-normal .listingcard:not(.open) .oi-listing > span:first-child {
  padding: 0 !important; font-size: .78rem; white-space: nowrap;
}
#orderlist.dens-normal .listingcard:not(.open) .oi-listing .ls-note {
  flex: 0 1 auto; padding: 0 !important; max-width: 100%;
}
#orderlist.dens-normal .listingcard:not(.open) .oi-listing button {
  padding: 3px 7px; font-size: .78rem;
}

/* 他の欄をひとまわり細くして、在庫数・価格の場所をつくる */
#orderlist.dens-normal .listingcard:not(.open) .oi-date { max-width: 124px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-cost { max-width: 92px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-f1 { max-width: 100px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-f2 { max-width: 118px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-f3 { max-width: 72px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-memo { max-width: 124px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-memo2 { max-width: 108px !important; }
#orderlist.dens-normal .listingcard:not(.open) .oi-nolisting {
  font-size: .76rem; margin: 0 !important;
}

/* --- 注文タブ: メモ欄 ------------------------------------------------
   もとの textarea は大きく高さを取るので、ここでは打ち消して
   入力欄と同じ見た目にし、中身に合わせて高さを伸ばす。              */
.memo-box {
  width: 100%;
  min-height: 0 !important;
  height: auto;
  font-family: inherit !important;
  font-size: .86rem !important;
  line-height: 1.3;
  padding: 4px 6px;
  resize: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.memo-box.long { font-size: .76rem !important; line-height: 1.25; }
.memo-box.xlong { font-size: .68rem !important; line-height: 1.2; }
#orderlist.dens-normal .listingcard:not(.open) .memo-box { padding: 3px 6px; }
#orderlist.dens-normal .listingcard:not(.open) .oi-memorow { align-items: flex-start; }

/* --- 送信中のお知らせ ------------------------------------------------
   フォームを送ってから画面が切り替わるまでの間、
   「動いている」ことが分かるように画面の下に出す。                  */
#busybar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 640px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: 0 6px 24px -8px rgba(0, 0, 0, .45);
  display: none;
}

/* 数量の欄は、上下の矢印をいつも出しておく。
   既定では「マウスを乗せたときだけ」出るブラウザが多く、
   矢印があること自体に気づけないため。 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  height: 22px;
}
input[type="number"] { -moz-appearance: number-input; }

/* 商品名のすぐ下の、国ごとの Shopee リンク */
.countrylinks { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.countrylink { display: inline-flex; gap: 6px; align-items: center; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--panel); }
.countrylink b { font-size: 11px; }
.countrylink a { text-decoration: none; }
.countrylink a:hover { text-decoration: underline; }

/* 表示▾ の設定（画面の幅・上の帯） */
.uiset { position: relative; }
.uiset > button { padding: 4px 10px; cursor: pointer; }
.uiset-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 300px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.uiset-pop[hidden] { display: none !important; }
.uiset-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.uiset-opts { display: inline-flex; gap: 0; }
.uiset-opts button { padding: 3px 9px; font-size: 12px; border-radius: 0; cursor: pointer; }
.uiset-opts button:first-child { border-radius: 6px 0 0 6px; }
.uiset-opts button:last-child { border-radius: 0 6px 6px 0; }
.uiset-opts button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
html.w-wide main { max-width: 1600px; }
html.w-full main { max-width: none; }
html.hc-hide #hcalc { display: none; }
html.hd-free header.topbar { position: static; }
html.hd-thin header.topbar { gap: 10px; }
html.hd-thin header.topbar .brand { padding: 6px 0; font-size: 14px; }
html.hd-thin header.topbar nav a { padding: 6px 9px; }
html.hd-thin .hcalc { padding: 2px 0; }

/* トラブル管理の中に注文タブを埋め込むとき（?embed=1）。注文のカードだけ出す */
body.embed header.topbar, body.embed #jobbar, body.embed .banner, body.embed footer { display: none !important; }
body.embed main { max-width: none; padding: 4px 4px 8px; }
body.embed main > *:not(section:has(#orderlist)) { display: none !important; }
body.embed section:has(#orderlist) { margin: 0; padding: 6px; border: 0; box-shadow: none; }
body.embed section:has(#orderlist) > *:not(#orderlist) { display: none !important; }

/* 上のメニューの並べ替え中 */
header.topbar nav a.nav-drag { opacity: .45; outline: 2px dashed var(--accent); outline-offset: -4px; }

/* 注文の状態で色分け（注文タブ・トラブル管理で共通） */
.o-cancelreq { background: rgba(239, 68, 68, .10) !important; border-left: 5px solid rgba(239, 68, 68, .55) !important; }
.o-cancel    { background: rgba(220, 38, 38, .26) !important; border-left: 5px solid rgb(220, 38, 38) !important; }
.o-shipped   { background: rgba(59, 130, 246, .10) !important; border-left: 5px solid rgba(59, 130, 246, .55) !important; }
.o-ordered   { background: rgba(249, 115, 22, .11) !important; border-left: 5px solid rgba(249, 115, 22, .55) !important; }
.o-trouble   { background: rgba(107, 114, 128, .16) !important; border-left: 5px solid rgba(107, 114, 128, .6) !important; }
/* 在庫0の欄は赤 */
input.ls-stock.zero { background: var(--err-bg) !important; color: var(--err) !important; border-color: var(--err) !important; font-weight: 700; }
.o-legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; margin: 0 0 8px; }
.o-legend span { padding: 2px 8px; border-radius: 4px; }

/* 画面の幅をドラッグで変える */
main { position: relative; }
html.w-px main { max-width: var(--main-w); }
.main-resize { position: absolute; top: 0; bottom: 0; width: 12px; cursor: col-resize; z-index: 5; touch-action: none; }
.main-resize.left { left: -6px; }
.main-resize.right { right: -6px; }
.main-resize::after { content: ''; position: sticky; top: 45vh; display: block; margin: 45vh auto 0; width: 4px; height: 56px;
  border-radius: 3px; background: var(--border); opacity: .7; transition: background .15s, opacity .15s; }
.main-resize:hover::after, .main-resize.drag::after { background: var(--accent); opacity: 1; }
body.embed .main-resize { display: none; }
@media (max-width: 760px) { .main-resize { display: none; } }

/* お知らせの帯を閉じる ✕ */
.banner-x { float: right; border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; color: inherit; opacity: .6; }
.banner-x:hover { opacity: 1; }

/* 上の帯の幅を ◀▶ のドラッグで変える */
html.hw-px header.topbar { max-width: var(--head-w); margin-left: auto; margin-right: auto; }
.head-resize { position: absolute; top: 50%; transform: translateY(-50%); width: 22px; height: 30px; display: flex; align-items: center;
  justify-content: center; font-size: 9px; letter-spacing: -2px; color: var(--muted); cursor: col-resize; touch-action: none;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel); opacity: .75; user-select: none; z-index: 11; }
.head-resize.left { left: 2px; }
.head-resize.right { right: 2px; }
.head-resize:hover, .head-resize.drag { opacity: 1; color: var(--accent); border-color: var(--accent); }
body.embed .head-resize { display: none; }
@media (max-width: 760px) { .head-resize { display: none; } }
header.topbar { padding-left: 30px; padding-right: 30px; }

/* 上の帯の高さを ▲▼ のドラッグで変える（入りきらないときは帯の中をスクロール） */
html.hh-px header.topbar { height: var(--head-h); overflow-y: auto; align-content: flex-start; }
.head-resize.top, .head-resize.bottom { left: 50%; top: auto; transform: translateX(-50%); width: 34px; height: 14px;
  font-size: 8px; letter-spacing: 0; cursor: row-resize; }
.head-resize.top { top: 0; }
.head-resize.bottom { bottom: 0; }

/* 注文の国名は、セルスマ(販売管理シート)と同じ色にする */
.tag.reg { background: var(--line, #e5e7eb); color: #1f2937; font-weight: 600; }
.tag.reg-PH { background: #8e7cc3; color: #fff; }
.tag.reg-MY { background: #ffd966; color: #3b2f00; }
.tag.reg-TH { background: #d5a6bd; color: #3b1228; }
.tag.reg-SG { background: #b7e1cd; color: #0b3d2a; }
/* 複数注文(違う商品の同梱・同じ商品の複数個・同じ買い手) セルスマの水色 */
.tag.multi { background: #cbe3eb; color: #0b3a4a; font-weight: 600; border: 1px solid #7fb9cc; }
.tag.repeat { background: #fde2ef; color: #7a1040; font-weight: 600; border: 1px solid #f0a6c8; }

/* 「仕入済み・受取済み・発送済み・保存」は、いつも商品名の下の行の左はしに出す。
   商品名の長さで、右に出たり下に出たりして、場所がばらばらになるのを防ぐ */
#orderlist.dens-normal .listingcard:not(.open) .oi-main > .oi-checks {
  order: 3; flex: 0 0 100% !important; justify-content: flex-start;
}
