/* app.css — ぼんじーラベル印刷くん（画面＋印刷）。色・余白は brand_bonzee.md に従う */
:root {
  --brand: #1A936F; --dark: #12684E; --tint: #E9F7F2; --ink: #1C1F1E; --muted: #5A625E;
  --rule: #D7DDDA; --paper: #FFFFFF; --alt: #F6F8F7; --warn: #B45309; --err: #B42318;
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 40px; --radius: 4px;
  --font: "Meiryo", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  /* 台紙（JSが上書き） */
  --page-w: 210mm; --page-h: 297mm; --label-w: 48.3mm; --label-h: 25.4mm;
  --cols: 4; --rows: 11; --ml: 8.4mm; --mt: 8.8mm; --gx: 0mm; --gy: 0mm;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--alt); }
h1, h2, h3 { line-height: 1.4; margin: 0; font-weight: 700; }
h1 { font-size: 20px; }
h2 { font-size: 18px; }
a { color: var(--dark); }
button { font: inherit; }
[hidden] { display: none !important; }

.topbar { height: 6px; background: var(--brand); }
.header { background: var(--paper); border-bottom: 1px solid var(--rule); }
.header .in { max-width: 1440px; margin: 0 auto; padding: 12px var(--s3); display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.header img { height: 28px; width: auto; display: block; }
.header h1 { font-size: 18px; }
.header .sp { flex: 1; }
.header nav a { margin-left: var(--s2); font-size: 15px; }
.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: var(--radius); border: 1px solid var(--rule); color: var(--muted); background: var(--paper); }
.badge.is-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.badge.is-warn { background: #FFF4E5; border-color: var(--warn); color: var(--warn); }
/* 有料機能の行：無料版では入力不可＋札 */
.paidBadge { font-size: 13px; padding: 1px 8px; margin-left: 6px; background: var(--tint); border-color: var(--brand); color: var(--dark); vertical-align: middle; }
.paidRow.is-locked .field input, .paidRow.is-locked .field select { background: var(--alt); color: var(--muted); cursor: not-allowed; }
body.is-paid .paidBadge { display: none; }

.main { max-width: 1440px; margin: 0 auto; padding: var(--s3); display: grid; grid-template-columns: minmax(400px, 520px) minmax(0, 1fr); gap: var(--s3); align-items: start; }
.opsCol, .previewCol { min-width: 0; }
@media (max-width: 1100px) { .main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .main { padding: var(--s2); } .card { padding: var(--s2); } .header .in { padding: 10px var(--s2); } .header nav a { margin-left: 0; margin-right: var(--s2); } }

.card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s3); margin-bottom: var(--s3); }
.card h2 { padding-bottom: var(--s1); border-bottom: 2px solid var(--tint); margin-bottom: var(--s2); }
.card h2 .step { display: inline-grid; place-items: center; width: 28px; height: 28px; background: var(--brand); color: #fff; font-size: 15px; margin-right: var(--s1); vertical-align: middle; }
.note { font-size: 14px; color: var(--muted); }
/* クラウド共有（未ログイン時）: チームプランでできること */
.cl-lead { margin: 0 0 var(--s1); font-size: 16px; font-weight: 700; color: var(--dark); }
.cl-feats { margin: 0 0 var(--s2); padding: var(--s2) var(--s2) var(--s2) var(--s3); list-style: none; background: var(--tint); border-radius: var(--radius); }
.cl-feats li { position: relative; padding-left: 4px; font-size: 15px; color: var(--ink); }
.cl-feats li + li { margin-top: 4px; }
.cl-feats li::before { content: "✓"; position: absolute; left: -18px; font-weight: 700; color: var(--brand); }
.cl-price { margin: 0; font-size: 15px; color: var(--ink); }
.callout { border-left: 4px solid var(--brand); padding: var(--s1) 0 var(--s1) var(--s2); background: var(--tint); font-size: 15px; margin: var(--s2) 0; }
.callout.warn { border-left-color: var(--warn); background: #FFF4E5; }

.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 14px; font-weight: 700; }
.field input, .field select { font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid #A9B3AE; border-radius: var(--radius); background: var(--paper); color: var(--ink); min-width: 0; }
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field input[type=number] { text-align: right; }
.field .hint { font-size: 13px; color: var(--muted); }
.grow { flex: 1 1 200px; }
.w-120 { width: 120px; } .w-160 { width: 160px; } .w-200 { width: 200px; }

.btn { display: inline-block; cursor: pointer; font-weight: 700; font-size: 15px; padding: 10px 20px; border-radius: var(--radius);
       border: 1px solid var(--brand); background: var(--brand); color: #fff; text-decoration: none; line-height: 1.3; white-space: nowrap; }
.btn:hover { background: var(--dark); border-color: var(--dark); }
.btn.ghost { background: var(--paper); color: var(--dark); }
.btn.ghost:hover { background: var(--tint); }
.btn.danger { background: var(--paper); color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: #FBEAE8; }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn.big { font-size: 17px; padding: 12px 28px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.msg { font-size: 14px; font-weight: 700; }
.msg.err { color: var(--err); } .msg.ok { color: var(--dark); }

.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { border: 1px solid var(--rule); padding: 8px 10px; text-align: left; vertical-align: middle; }
.table thead th { background: var(--brand); color: #fff; font-size: 14px; position: sticky; top: 0; }
.table tbody tr:nth-child(even) { background: var(--alt); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .code { font-family: Consolas, Menlo, monospace; font-size: 15px; }
.table .act { white-space: nowrap; width: 1%; }
.table .act .btn { margin-right: 4px; }
.tablewrap { max-height: 300px; overflow: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tablewrap .table th, .tablewrap .table td { border-left: 0; border-right: 0; }

.picklist { border: 1px solid #A9B3AE; border-radius: var(--radius); max-height: 200px; overflow: auto; background: var(--paper); }
.picklist .item { padding: 8px 12px; cursor: pointer; font-size: 15px; border-bottom: 1px solid var(--rule); display: flex; gap: var(--s2); }
.picklist .item:last-child { border-bottom: 0; }
.picklist .item:hover { background: var(--tint); }
.picklist .item.sel { background: var(--tint); font-weight: 700; border-left: 4px solid var(--brand); }
.picklist .item .jan { color: var(--muted); font-family: Consolas, Menlo, monospace; margin-left: auto; }
.picklist .empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }
.selected { font-size: 15px; margin-top: 6px; }

details { border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s1) var(--s2); margin-top: var(--s2); background: var(--alt); }
details summary { cursor: pointer; font-weight: 700; font-size: 15px; }
details[open] summary { margin-bottom: var(--s2); }
.cfg { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin-bottom: var(--s2); }
.cfg .field input { padding: 6px 8px; }
.cfg .field label { font-size: 13px; }
.opts { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.opts label { font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.opts select { font: inherit; font-size: 15px; padding: 6px 8px; border: 1px solid #A9B3AE; border-radius: var(--radius); }

/* ===== 右：プレビュー ===== */
.previewCol { position: sticky; top: var(--s3); }
.previewBar { display: flex; align-items: center; gap: var(--s2); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s2) var(--s3); margin-bottom: var(--s2); flex-wrap: wrap; }
.previewBar .sum { font-size: 16px; font-weight: 700; }
.previewBar .sum small { font-weight: 400; color: var(--muted); font-size: 14px; }
.previewBar .sp { flex: 1; }
.previewWrap { background: #CFD6D2; padding: var(--s3); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 140px); }
.previewCol .note { margin-top: var(--s1); }

.sheet { width: var(--page-w); height: var(--page-h); background: #fff; margin: 0 auto var(--s2); position: relative;
         padding: var(--mt) 0 0 var(--ml); display: grid;
         grid-template-columns: repeat(var(--cols), var(--label-w)); grid-template-rows: repeat(var(--rows), var(--label-h));
         column-gap: var(--gx); row-gap: var(--gy); align-content: start; justify-content: start; break-after: page; }
.sheet:last-child { break-after: auto; }
.label { width: var(--label-w); height: var(--label-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
         padding: 0.8mm; overflow: hidden; outline: 0.2mm dashed #B9C2BD; outline-offset: -0.2mm; }
.label.blank { outline-color: #E3E8E5; }
.label svg { display: block; height: auto; }
.label .bc.wide svg text { font-weight: 400; }   /* GS1-128・CODE39・NW-7（ラベル幅いっぱいに描くもの） */
.label .name { font-weight: 700; line-height: 1.15; margin-top: 0.5mm; text-align: center; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; overflow-wrap: anywhere; word-break: normal; }
.label .memo { font-weight: 500; line-height: 1; margin-top: 0.5mm; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pageNo { position: absolute; right: 0; bottom: -18px; font-size: 13px; color: var(--muted); }
/* 位置合わせ用シート：枠(実線)と番号だけ。印刷でも消さない */
.label.calib { outline: none; border: 0.25mm solid #000; align-items: flex-start; justify-content: flex-start; padding: 0.6mm 1mm; }
.label.calib .calibNo { font-size: 2.6mm; line-height: 1; color: #000; }
.calibInfo { position: absolute; left: 4mm; bottom: 2mm; font-size: 2.6mm; color: #000; white-space: nowrap; }
@media print { .label.calib { border: 0.25mm solid #000 !important; } }

@media print {
  html, body { background: #fff; margin: 0; padding: 0; }
  .topbar, .header, .opsCol, .previewBar, .previewCol .note, .pageNo, .noprint { display: none !important; }
  .main { display: block; padding: 0; margin: 0; max-width: none; }
  .previewCol { position: static; }
  .previewWrap { background: #fff; padding: 0; border-radius: 0; overflow: visible; max-height: none; }
  .sheet { margin: 0; box-shadow: none; }
  .label { outline: none !important; }
}

/* 商品一覧のポップアップ（50件ずつページ送り） */
.dlg { width: min(720px, 92vw); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s3); background: #fff; color: inherit; }
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlgHead { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.dlgHead h3 { margin: 0; flex: 1 1 auto; font-size: 18px; }
.dlgFoot { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); }
.dlgFoot .note { flex: 1 1 auto; text-align: center; }
.dlgFoot .btn[disabled] { opacity: .45; cursor: default; }
