:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --line: #e3e0db;
  --ink: #2b2723;
  --muted: #8a837a;
  --accent: #7a5c3e;
  --accent-ink: #ffffff;
  --ok: #2e7d52;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ===== ヘッダー ===== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.app-header h1 { margin: 0; font-size: 17px; font-weight: 700; }
.app-header .sub { font-size: 12px; opacity: .85; }

.meta-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 8px 14px; font-size: 13px;
}
.meta-bar label { color: var(--muted); margin-right: 4px; }
.meta-bar input[type="date"], .meta-bar input[type="text"] {
  font-size: 15px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
}

/* ===== カテゴリタブ ===== */
.tabs {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab .badge {
  display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px;
  font-size: 11px; line-height: 18px; text-align: center;
  background: var(--ok); color: #fff; border-radius: 999px;
}
.tab.active .badge { background: rgba(255,255,255,.3); }

/* ===== 商品リスト ===== */
.list { padding: 8px 10px 120px; }
.section { display: none; }
.section.active { display: block; }
.section h2 { font-size: 15px; margin: 6px 4px 10px; }

.row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 7px; box-shadow: var(--shadow);
}
.row .name { font-size: 15px; font-weight: 600; }
.row.filled { border-color: var(--accent); background: #fcfaf7; }

.field { display: flex; flex-direction: column; align-items: center; }
.field .lbl { font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-size: 20px; line-height: 1; color: var(--accent); cursor: pointer;
}
.stepper button:active { background: #f0ebe4; }
.stepper input {
  width: 46px; height: 34px; text-align: center; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}

textarea#note {
  width: 100%; min-height: 110px; font-size: 15px; padding: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}

/* ===== 送信フッター ===== */
.footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.footer .summary { font-size: 13px; color: var(--muted); }
.footer .summary b { color: var(--ink); font-size: 16px; }
.btn {
  border: none; border-radius: 10px; padding: 12px 18px; font-size: 16px; font-weight: 700;
  background: var(--accent); color: #fff; cursor: pointer;
}
.btn:disabled { opacity: .45; }
.btn.secondary { background: #fff; color: var(--accent); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 600; }

/* ===== トースト ===== */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 60; opacity: 0; transition: opacity .25s; pointer-events: none;
  max-width: 90%;
}
.toast.show { opacity: 1; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

/* ===== 本店：一覧 ===== */
.wrap { max-width: 960px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
table.listtbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
table.listtbl th, table.listtbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
table.listtbl th { background: #faf8f5; color: var(--muted); font-weight: 600; }
table.listtbl tr:last-child td { border-bottom: none; }
.open-btn { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--accent); background: #fff; color: var(--accent); font-weight: 700; cursor: pointer; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ===== 本店：印刷ビュー ===== */
.sheet { background: #fff; color: #000; }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-head .info { font-size: 13px; }
.cat-title { font-size: 14px; font-weight: 700; margin: 12px 0 4px; border-left: 5px solid var(--accent); padding-left: 6px; }
.print-grid { display: grid; gap: 0 14px; }
.print-grid.c2 { grid-template-columns: 1fr 1fr; }
.print-grid.c1 { grid-template-columns: 1fr; }
table.ptbl { width: 100%; border-collapse: collapse; }
table.ptbl th, table.ptbl td { border: 1px solid #999; padding: 3px 6px; font-size: 12px; }
table.ptbl th { background: #f0f0f0; font-weight: 600; text-align: center; }
table.ptbl td.n { text-align: center; width: 46px; }
table.ptbl td.val { font-weight: 700; }
.note-box { border: 1px solid #999; padding: 6px 8px; margin-top: 10px; font-size: 12px; white-space: pre-wrap; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }

@media (min-width: 560px) {
  .row .name { font-size: 16px; }
}

/* ===== 商品マスタ編集（admin） ===== */
.admin-toolbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: rgba(246,245,243,.97); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: 12px 16px;
}
.admin-toolbar .status { font-size: 13px; color: var(--muted); margin-left: auto; }
.admin-toolbar .status.dirty { color: var(--danger); font-weight: 700; }

.cat-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.cat-card.off { opacity: .55; }
.cat-head {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: #faf8f5; border-bottom: 1px solid var(--line); padding: 10px 12px;
}
.cat-head .order { display: flex; flex-direction: column; gap: 2px; }
.cat-head .cat-name { font-size: 16px; font-weight: 700; flex: 1 1 200px; min-width: 140px; }
.cat-head .col2-field { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.cat-head select, .cat-head input, .prow input, .prow select {
  font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.prod-area { padding: 8px 12px 12px; }
.prow {
  display: flex; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line);
}
.prow:last-child { border-bottom: none; }
.prow.off { opacity: .5; }
.prow .pname { flex: 1 1 auto; min-width: 120px; }
.prow .order { display: flex; gap: 3px; }
.mini-btn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--accent); font-size: 15px; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.mini-btn:hover { background: #f0ebe4; }
.mini-btn.del { color: var(--danger); }
.mini-btn.on { background: var(--ok); color: #fff; border-color: var(--ok); }
.mini-btn:disabled { opacity: .3; cursor: default; }
.add-prod { margin-top: 8px; }
.toggle {
  font-size: 12px; padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; color: var(--muted); flex: 0 0 auto;
}
.toggle.on { background: var(--ok); color: #fff; border-color: var(--ok); }
.hint { font-size: 12px; color: var(--muted); margin: 4px 2px 14px; }

/* ===== 印刷時 ===== */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; }
  .cat-block { break-inside: avoid; }
  table.ptbl tr { break-inside: avoid; }
}
