* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: #f6f5f2;
  color: #2b2b2b;
  font-size: 15px;
  line-height: 1.55;
}
.hidden { display: none !important; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 18px 0 8px; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ===== 共通部品 ===== */
.btn {
  display: inline-block;
  border: 1px solid #2b2b2b;
  background: #2b2b2b;
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
}
.btn.sub { background: #fff; color: #2b2b2b; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn.danger { background: #fff; color: #b3261e; border-color: #b3261e; }
.btn:disabled { opacity: .5; }
.card {
  background: #fff;
  border: 1px solid #e3e0d9;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eee;
  color: #444;
  white-space: nowrap;
}
.badge.st-販売中 { background: #e3f2e1; color: #256b1e; }
.badge.st-売約済み { background: #fde8e0; color: #a33b12; }
.badge.st-発送完了 { background: #e0e9fd; color: #274b9f; }
.badge.st-未出品 { background: #eee; color: #666; }
.badge.kind { background: #f3e8d2; color: #7a5b12; }
.muted { color: #777; font-size: 13px; }
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #2b2b2b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200;
  max-width: 92vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== ログイン ===== */
.login-wrap { max-width: 380px; margin: 8vh auto 0; padding: 0 16px; }
.login-wrap .card { padding: 20px; }
.login-wrap h1 { text-align: center; margin-bottom: 4px; }
.login-wrap .sub { text-align: center; color: #777; font-size: 13px; margin-bottom: 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: #555; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #cfccc4;
  border-radius: 8px;
  background: #fff;
}
.error { color: #b3261e; font-size: 13px; min-height: 1.2em; margin: 6px 0; }
.w100 { width: 100%; }

/* ===== アプリ枠 ===== */
header.app {
  background: #2b2b2b;
  color: #fff;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
header.app .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
header.app .logout { background: transparent; border: 1px solid #888; color: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.summary { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  background: #3d3d3d;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.chip b { display: block; font-size: 16px; }
nav.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #e3e0d9;
  position: sticky;
  top: 0;
  z-index: 40;
  overflow-x: auto;
}
nav.tabs button {
  flex: 1;
  min-width: 86px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 11px 4px;
  font-size: 14px;
  color: #666;
  white-space: nowrap;
}
nav.tabs button.active { color: #2b2b2b; border-bottom-color: #2b2b2b; font-weight: 700; }
main { max-width: 960px; margin: 0 auto; padding: 14px 12px 60px; }

/* ===== 一覧 ===== */
.controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.controls input[type="search"] {
  flex: 1 1 180px;
  padding: 9px 10px;
  border: 1px solid #cfccc4;
  border-radius: 8px;
  background: #fff;
}
.controls select {
  padding: 9px 8px;
  border: 1px solid #cfccc4;
  border-radius: 8px;
  background: #fff;
}
.item-card { display: flex; gap: 10px; align-items: flex-start; }
.item-card img.thumb {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; background: #eee;
}
.item-main { flex: 1; min-width: 0; }
.item-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.item-top .code { font-size: 12px; color: #888; font-variant-numeric: tabular-nums; }
.item-name { font-weight: 600; margin: 2px 0; overflow-wrap: anywhere; }
.item-sub { font-size: 13px; color: #555; }
.item-sub .profit { color: #256b1e; font-weight: 600; }
.item-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
img.thumb-lg { width: 84px; height: 84px; }

/* ===== テーブル ===== */
table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
th, td { border: 1px solid #e3e0d9; padding: 7px 8px; text-align: left; vertical-align: top; }
th { background: #f0eee8; font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; background: #faf8f3; }
.table-scroll { overflow-x: auto; border-radius: 10px; }

/* ===== モーダル ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  overflow-y: auto;
  padding: 12px;
}
.modal .sheet {
  background: #fff;
  border-radius: 12px;
  max-width: 640px;
  margin: 12px auto;
  padding: 16px;
}
.modal .sheet h2 { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.form-actions .spacer { flex: 1; }
.imgs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.imgs img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: #eee; }

/* ===== 委託・設定 ===== */
.settle-section { margin-bottom: 22px; }
.settle-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.settle-head h2 { margin: 0; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input {
  padding: 9px 10px; border: 1px solid #cfccc4; border-radius: 8px; background: #fff;
}
.result { margin-top: 8px; font-size: 14px; }
.section-box { margin-bottom: 26px; }

/* ===== 印刷（精算表だけ） ===== */
@media print {
  body.printing * { visibility: hidden; }
  body.printing .print-target, body.printing .print-target * { visibility: visible; }
  body.printing .print-target {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    background: #fff;
  }
  body.printing .print-target .no-print { display: none !important; }
}
