/* 棚スキャ — 見た目。明るい画面・暗い画面は端末の設定に合わせる。押す所は44px以上（大事なボタンは48px）、字は12px以上。 */
:root {
  --bg: #f3f5f8; --card: #ffffff; --fg: #17202b; --muted: #5f6b7d; --line: #e2e6ec;
  --accent: #0f766e; --accent-fg: #ffffff;
  --great: #0f9d58; --ok: #2563eb; --warn: #b45309; --bad: #dc2626; --unk: #6b7280;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1319; --card: #182029; --fg: #e8edf4; --muted: #a3b0c0; --line: #2a3542; --accent: #34d3c3; --accent-fg: #04201c; --warn: #f59e0b; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Noto Sans JP", "Hiragino Sans", sans-serif; }
body { overscroll-behavior: none; }
[hidden] { display: none !important; }
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 640px; margin: 0 auto; }
#top { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 6px) 12px 6px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.net { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.net::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--great); }
.net.off::before { background: var(--bad); }
.net.warn::before { background: var(--warn); }
main { flex: 1; overflow: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
#tabs { display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs a { flex: 1; text-align: center; padding: 8px 4px 6px; min-height: 52px; color: var(--muted); text-decoration: none; font-size: 12px; position: relative; }
#tabs a b { display: block; font-size: 20px; line-height: 1.2; font-weight: 400; }
#tabs a.on { color: var(--accent); font-weight: 700; }
#tabs .badge { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--bad); color: #fff; border-radius: 10px; font-size: 12px; padding: 0 6px; min-width: 18px; }

/* 共通の部品 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 12px; min-height: 48px; padding: 0 16px; font: inherit; font-weight: 600; cursor: pointer; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .5; }
.card > .btn.primary { width: 100%; margin: 8px 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--fg); padding: 6px 12px; font: inherit; font-size: 14px; min-height: 44px; }
.seg button.on { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.banner { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--warn); background: var(--card); margin-bottom: 12px; font-size: 14px; }
.banner.bad { border-color: var(--bad); }
button.banner { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; color: var(--fg); min-height: 44px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); color: var(--muted); }
.chip.good { color: var(--great); border-color: var(--great); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.bad { color: var(--bad); border-color: var(--bad); }

/* カメラ。自動で止まった時は同じ大きさのまま（下の結果が動かない）。「止める」を押した時だけ小さくする */
.cam { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 10; margin-bottom: 8px; }
.cam.off { aspect-ratio: auto; height: 110px; }
.cam.off.keep { aspect-ratio: 16 / 10; height: auto; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam.off video { visibility: hidden; }
.cam .guide { position: absolute; left: 10%; right: 10%; top: 35%; height: 30%; border: 2px solid rgba(52, 211, 153, .95); border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .28); pointer-events: none; }
.cam .guide.sq { left: 18%; right: 18%; top: 10%; height: 80%; }
.cam.off .guide { display: none; }
.cam .msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; }
.cam .start { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cam:not(.off) .start { display: none; }
.cam .start .btn { min-height: 64px; font-size: 20px; padding: 0 28px; }
.camtools { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.camtools .btn { flex: 1; min-width: 70px; }
.manual { display: flex; gap: 8px; margin-bottom: 12px; }
.manual input { flex: 1; min-width: 0; }

/* 判定の印。仮の判定（仕入値の前）は点線の輪と「仮」の札 */
.mark { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; font-size: 24px; font-weight: 800; color: #fff; flex: none; }
.mark.m-great { background: var(--great); }
.mark.m-ok { background: var(--ok); }
.mark.m-warn { background: var(--warn); }
.mark.m-bad { background: var(--bad); }
.mark.m-unk { background: var(--unk); }
.mark.m-none { background: var(--line); color: var(--muted); }
.mark.pending { outline: 2px dashed var(--muted); outline-offset: 2px; }
.mark .kari { position: absolute; right: -6px; bottom: -6px; font-style: normal; font-size: 12px; line-height: 1; font-weight: 800; padding: 3px 4px; border-radius: 6px; background: var(--card); color: var(--fg); border: 1px solid var(--muted); }
.mark.big { width: 64px; height: 64px; font-size: 36px; }

/* スキャンの結果（いちばん上の大きい札と、その下の一覧） */
.hero > * + * { margin-top: 10px; }
.hero .head { display: flex; gap: 12px; align-items: flex-start; }
.hero .thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--line); flex: none; }
.hero .t { font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thumb.zoomable { cursor: zoom-in; }
.item { display: flex; gap: 10px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; color: inherit; text-decoration: none; }
.item .thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.item .mark { width: 36px; height: 36px; font-size: 20px; }
.item .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.item .m { font-size: 13px; color: var(--muted); margin-top: 2px; }
.reasons { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.cands { display: grid; gap: 8px; margin-top: 10px; }
.cand { display: flex; gap: 10px; align-items: center; text-align: left; padding: 8px; min-height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }
.cand img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--line); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .wide { grid-column: 1 / -1; }
.actions .btn { min-height: 48px; padding: 0 6px; font-size: 15px; line-height: 1.25; }
.multi { display: inline-flex; align-items: center; margin-top: 4px; min-height: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--warn); background: transparent; color: var(--warn); font: inherit; font-size: 14px; font-weight: 700; }

/* ひと目で見る5つ（新品値段・粗利・目標仕入れ額・現在順位＋複数カタログ）2026-10-09 本人指定 */
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.fact { background: var(--bg); border-radius: 10px; padding: 6px 3px 5px; text-align: center; min-width: 0; }
.fact .fl { display: block; font-size: 12px; font-weight: 700; color: var(--muted); line-height: 1.2; }
.fact b { display: block; font-size: 18px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fact small { font-size: 12px; color: var(--muted); line-height: 1.2; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fact.neg b { color: var(--bad); }
@media (max-width: 345px) { .facts { grid-template-columns: repeat(2, 1fr); } }
.mini { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 6px; margin-top: 4px; font-size: 13px; color: var(--fg); }
.mini .mc small { display: block; font-size: 12px; color: var(--muted); line-height: 1.2; }
.mini .mc b { display: block; font-size: 13px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .mc.neg b { color: var(--bad); }

/* 詳細・設定・リスト */
h2.sec { font-size: 14px; color: var(--muted); margin: 16px 4px 6px; font-weight: 700; }
.kv { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-size: 14px; word-break: break-all; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field > label, .field > span.l { flex: 1; }
.field small { display: block; color: var(--muted); font-size: 12px; }
.field input[type=text], .field input[type=number], .field select { width: 46%; }
input[type=text], input[type=number], input[type=search], input[type=password], select { font: inherit; min-height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
input[type=range] { width: 100%; }
.chart { width: 100%; height: 280px; display: block; touch-action: pan-y; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 700; }
.lrow { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lrow:last-child { border-bottom: 0; }
.lrow .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.lrow .lt { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lrow .btn.small { min-width: 44px; }
.offers .orow { display: grid; grid-template-columns: 5.5em 1fr auto; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.offers .orow:last-child { border-bottom: 0; }
.offers .orow.am b { color: var(--warn); }
.bigimg { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: #fff; border-radius: 12px; }
.steps { margin: 6px 0 12px; padding-left: 22px; }
.steps li { margin-bottom: 6px; }

/* 下から出る板・数字ボタン・お知らせ */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { width: 100%; max-width: 640px; background: var(--card); border-radius: 18px 18px 0 0; padding: 14px 14px calc(env(safe-area-inset-bottom) + 14px); max-height: 90vh; max-height: 90dvh; overflow: auto; }
.sheet-title { font-weight: 800; margin-bottom: 6px; }
.sheet-msg { margin: 8px 0 14px; }
.kp-head { display: flex; gap: 10px; align-items: center; padding: 6px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.kp-head .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.kp-head .t { font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kp-mode { display: flex; margin: 4px 0 2px; }
.kp-mode button { flex: 1; }
.kp-disp { font-size: 34px; font-weight: 800; text-align: right; padding: 6px 4px 2px; border-bottom: 2px solid var(--accent); font-variant-numeric: tabular-nums; }
.kp-sub { min-height: 18px; text-align: right; font-size: 13px; color: var(--muted); padding: 2px 4px 0; }
.kp-prev { min-height: 20px; font-size: 14px; font-weight: 700; padding: 2px 4px 8px; }
.kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.kp-key { min-height: 56px; font-size: 24px; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-family: inherit; }
.kp-key.sub { color: var(--muted); }
.kp-actions { display: flex; gap: 8px; margin-top: 12px; }
.kp-actions .btn { flex: 1; padding: 0 8px; }
.pick { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 12px; min-height: 52px; margin-bottom: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; color: var(--fg); font: inherit; text-align: left; }
.pick small { color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 76px); transform: translateX(-50%) translateY(16px); background: rgba(17, 24, 39, .92); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90%; z-index: 60; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }
