:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #636c76;
  --line: #d8dee4;
  --accent: #0b6bcb;
  --accent-text: #ffffff;
  --in-bg: #e6f4ea;
  --in-text: #136c2e;
  --error: #b42318;
  --ok: #136c2e;
  --warn: #9a4b00;
  --mfn-bg: #e8f0fe;
  --mfn-text: #0b57d0;
  --fba-bg: #fff4e5;
  --fba-text: #9a4b00;
  --new-bg: #fde7ef;
  --new-text: #b0124a;
  --day-bg: #24364d;
  --day-text: #ffffff;
  --checked-bg: #f0f7f1;
  --memo-bg: #fff8d6;
  --memo-line: #e0b400;
  --memo-text: #4a3a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --card: #1f2329;
    --text: #e6e8eb;
    --muted: #9aa4af;
    --line: #353b43;
    --accent: #4a9eff;
    --accent-text: #0b1320;
    --in-bg: #173b25;
    --in-text: #8fe3a8;
    --error: #ff8a80;
    --ok: #8fe3a8;
    --warn: #ffc27a;
    --mfn-bg: #1c2f4d;
    --mfn-text: #9cc2ff;
    --fba-bg: #3d2a12;
    --fba-text: #ffc27a;
    --new-bg: #4a1729;
    --new-text: #ff9fc0;
    --day-bg: #2f4f78;
    --day-text: #ffffff;
    --checked-bg: #18261c;
    --memo-bg: #3a3112;
    --memo-line: #d4a800;
    --memo-text: #ffe8a3;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); }
button, input, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  min-height: 36px;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.link { border: none; background: none; color: var(--accent); padding: 6px 4px; }
button:disabled { opacity: 0.5; cursor: default; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: var(--bg);
}

.login { max-width: 360px; margin: 48px auto; padding: 0 16px; }
.login label { display: block; margin-top: 12px; font-weight: 600; }
.login input { margin-top: 4px; }
.login button { margin-top: 16px; width: 100%; }

.top {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}
#refreshMsg:empty { display: none; }
#refreshMsg.busy { color: var(--accent); font-weight: 600; }
#refreshMsg.ng { color: var(--error); }
#refreshMsg.ok { color: var(--ok); }
.top-row, .tabs, .filters, #statusLine, #refreshMsg { max-width: 1368px; margin-left: auto; margin-right: auto; }
.top-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-row #storeLabel { margin-right: auto; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.filters #searchBox { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 4px; margin-top: 8px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 6px 10px; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.check { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.check input { width: auto; }

main { max-width: 1400px; margin: 0 auto; padding: 8px 16px 16px; }
/* 日付の見出し: 日付の切り替わりが分かるよう、色の帯にして日付ごとに間をあける(2026-10-15) */
.day + .day { margin-top: 28px; }
.day h2 {
  font-size: 17px; margin: 18px 0 8px; padding: 8px 12px;
  background: var(--day-bg); color: var(--day-text); border-radius: 8px;
}
.day h2 .muted { font-weight: normal; font-size: 13px; color: inherit; opacity: 0.85; }
.day h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.check-progress { font-size: 13px; font-weight: 600; }
.check-progress.done::before { content: "✓ "; }
.check-all { min-height: 30px; padding: 3px 12px; font-size: 13px; font-weight: 600; background: #ffffff; color: #24364d; border-color: #ffffff; }
/* 確認チェック */
.col-check { width: 64px; text-align: center; }
.check-box { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font-size: 12px; color: var(--muted); }
.check-box input { width: 26px; height: 26px; margin: 0; cursor: pointer; accent-color: var(--ok); }
.checked-at { color: var(--ok); font-size: 11px; line-height: 1.3; }
tr.item.is-checked, tr.item.is-checked td { background: var(--checked-bg); }
tr.item.is-checked .check-text { color: var(--ok); font-weight: 600; }
.empty { padding: 24px 0; color: var(--muted); }

/* 一覧の表 */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table.items { width: 100%; border-collapse: collapse; font-size: 14px; }
table.items th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg);
}
table.items td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.items tr:last-child td { border-bottom: none; }
.col-img { width: 112px; }
.col-item { min-width: 220px; }
.col-stock { white-space: nowrap; }
.col-in { width: 150px; min-width: 150px; max-width: 150px; }
.col-name { width: 240px; min-width: 200px; }
.col-memo { min-width: 260px; }
.field label.m-only, label.m-only { display: none; }

.thumb { width: 96px; height: 96px; object-fit: contain; display: block; background: #fff; border-radius: 4px; }
.thumb.none { visibility: hidden; }
.title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.asin { font-family: ui-monospace, monospace; font-size: 13px; color: var(--accent); }
.arrived { color: var(--in-text); font-weight: 600; }
.arrived div { background: var(--in-bg); border-radius: 4px; padding: 1px 8px; margin-bottom: 2px; display: inline-block; }
.changes summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.changes ul { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; line-height: 1.4; }
.changes li { padding: 3px 0; border-top: 1px dashed var(--line); white-space: nowrap; }
.changes li .when { color: var(--muted); }
.stopped { margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.kind { display: inline-block; border-radius: 4px; padding: 0 8px; margin-bottom: 4px; font-size: 12px; font-weight: 700; }
.kind.new { background: var(--new-bg); color: var(--new-text); }
.kind.restock { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.kind:empty { display: none; }
.kind-head { font-size: 14px; margin: 12px 0 6px; padding-left: 8px; border-left: 4px solid var(--line); }
.kind-head.new { border-left-color: var(--new-text); color: var(--new-text); }
.kind-head .muted { font-weight: normal; font-size: 13px; }
.col-stock > div { margin-bottom: 3px; }
.col-stock .has { display: inline-block; border-radius: 4px; padding: 1px 8px; font-weight: 700; font-size: 15px; }
.col-stock .stock-mfn.has { background: var(--mfn-bg); color: var(--mfn-text); }
.col-stock .stock-fba.has { background: var(--fba-bg); color: var(--fba-text); }
.col-stock .zero { color: var(--muted); padding: 1px 8px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { display: flex; cursor: pointer; position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { padding: 6px 14px; border-left: 1px solid var(--line); background: var(--card); white-space: nowrap; }
.seg label:first-child span { border-left: none; }
.seg input:checked + span { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.memo { display: block; width: 100%; resize: vertical; }
.memo.has-memo { background: var(--memo-bg); border: 2px solid var(--memo-line); color: var(--memo-text); font-weight: 600; }
.memo-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; }
.memo-msg.ok, .name-state.ok { color: var(--ok); font-weight: 600; }
.memo-msg.ng, .name-state.ng { color: var(--error); font-weight: 600; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.count { color: var(--muted); }
.name-state.ok { color: var(--ok); font-weight: 600; }
.name-state.pending { color: var(--warn); font-weight: 600; }
.col-name input { width: 100%; }
.col-decide { white-space: nowrap; }
.save-name:not(:disabled) { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.count.over { color: var(--error); }
.more { text-align: center; padding: 8px 16px 32px; }

/* スマホ幅: 表の行を縦積みにする */
@media (max-width: 760px) {
  .top-row h1 { font-size: 18px; }
  .table-wrap { overflow: visible; }
  table.items thead { display: none; }
  table.items, table.items tbody { display: block; }
  table.items tr {
    display: grid; grid-template-columns: 88px 1fr; column-gap: 10px; row-gap: 4px;
    padding: 10px; border-bottom: 1px solid var(--line);
  }
  table.items tr:last-child { border-bottom: none; }
  table.items td { display: block; padding: 0; border: none; width: auto; min-width: 0; max-width: none; white-space: normal; }
  .col-img { grid-row: span 3; }
  .col-check { grid-column: 1 / -1; text-align: left; display: flex !important; align-items: center; gap: 10px; }
  .check-box { flex-direction: row; gap: 8px; font-size: 14px; }
  .day-tools { margin-left: 0; width: 100%; justify-content: space-between; }
  .thumb { width: 88px; height: 88px; }
  .col-stock { display: flex !important; gap: 8px; align-items: center; flex-wrap: wrap; }
  .col-stock > div { margin-bottom: 0; }
  .col-name, .col-decide, .col-memo { grid-column: 1 / -1; margin-top: 4px; }
  .col-decide button { width: 100%; }
  .field label.m-only, label.m-only { display: block; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
}
