:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --border: #e3e0d8;
  --ink: #1c1b19;
  --ink-soft: #6b675e;
  --accent: #a8925f;
  --accent-dark: #8a7549;
  --danger: #b3492f;
  --header: #171614;
  --radius: 10px;
  font-family: "Yu Gothic UI", "Meiryo", "Hiragino Kaku Gothic ProN", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

/* ---------- Header ---------- */
.topbar {
  background: var(--header);
  color: #f4f2ec;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand { display: flex; align-items: baseline; gap: 16px; }
.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.brand-sub {
  font-size: 12px;
  color: #cfcabf;
  line-height: 1.4;
}
.brand-sub small { letter-spacing: 0.08em; font-size: 10px; color: #948e7f; }

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.fair-select { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #cfcabf; }
.fair-select select {
  background: #2a2824;
  color: #f4f2ec;
  border: 1px solid #4a463d;
  border-radius: 6px;
  padding: 6px 10px;
}

/* ---------- Status bar ---------- */
.statusbar {
  background: #fffdf8;
  border-bottom: 1px solid var(--border);
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.status-left { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #e8a33d; display: inline-block; }
.statusbar code {
  background: #efece3;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f1efe8; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }
.topbar .btn-ghost { color: #f4f2ec; }
.topbar .btn-ghost:hover { background: rgba(255,255,255,0.12); }
.btn-outline { background: var(--panel); border-color: var(--border); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { background: #cfcabf; border-color: #cfcabf; cursor: not-allowed; }
.btn-block { width: 100%; padding: 12px; margin-top: 12px; font-size: 15px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1.3fr 1.4fr 1fr;
  gap: 16px;
  padding: 20px 28px;
  align-items: start;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .product-list, .cart-list { max-height: none; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel h2 { font-size: 15px; margin: 0 0 10px; }

/* ---------- Catalog ---------- */
.search-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
}

.filter-box {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  background: #faf9f5;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.filter-box label { display: flex; flex-direction: column; font-size: 12px; color: var(--ink-soft); gap: 4px; }
.filter-box select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.hidden { display: none !important; }

.product-list { max-height: 640px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }

.product-card {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.product-card:hover { border-color: var(--accent); }
.product-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #fbf8f1; }

.product-thumb {
  width: 76px;
  height: 92px;
  object-fit: cover;
  border-radius: 6px;
  background: #eeece5;
  flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-topline { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.sku-badge {
  font-size: 11px;
  background: #efece3;
  color: var(--ink-soft);
  padding: 2px 6px;
  border-radius: 4px;
}
.fair-tag { font-size: 11px; color: var(--ink-soft); }
.price-line { margin-left: auto; text-align: right; }
.price-main { font-weight: 700; font-size: 15px; }
.price-tax { font-size: 11px; color: var(--ink-soft); }

.product-name { font-size: 14px; font-weight: 600; margin: 2px 0; }
.series-tag {
  display: inline-block;
  font-size: 11px;
  background: #f1e9d8;
  color: var(--accent-dark);
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 4px;
}
.product-meta { font-size: 12px; color: var(--ink-soft); display: flex; gap: 10px; flex-wrap: wrap; }

.list-footer { margin-top: 10px; font-size: 12px; color: var(--ink-soft); text-align: right; }

/* ---------- Tabs / center panel ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.empty-state { text-align: center; color: var(--ink-soft); padding: 60px 20px; }
.empty-state.small { padding: 30px 10px; }
.empty-icon { font-size: 32px; margin-bottom: 10px; }
.empty-sub { font-size: 12px; margin-top: 6px; }

.option-detail { display: flex; gap: 18px; flex-wrap: wrap; }
.option-image { width: 220px; height: 270px; object-fit: cover; border-radius: 8px; background: #eeece5; flex-shrink: 0; }
.option-main { flex: 1; min-width: 220px; }
.option-main h3 { margin: 0 0 4px; font-size: 18px; }
.option-price { font-size: 20px; font-weight: 700; margin: 6px 0; }
.option-price small { font-size: 12px; color: var(--ink-soft); font-weight: 400; margin-left: 6px; }
.option-specs { font-size: 12px; color: var(--ink-soft); margin-bottom: 12px; display: flex; gap: 12px; flex-wrap: wrap; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
}
.chip.active { border-color: var(--accent); background: var(--accent); color: #fff; }

.qty-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.qty-row input { width: 70px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; }

/* ---------- Customer form ---------- */
.privacy-banner {
  background: #fbf3e3;
  border: 1px solid #eadfc0;
  color: #6b5a2c;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}
.customer-form { display: flex; flex-direction: column; gap: 12px; }
.customer-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-soft); }
.customer-form input, .customer-form textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  resize: vertical;
}
.required { color: var(--danger); font-size: 10px; border: 1px solid var(--danger); padding: 1px 5px; border-radius: 4px; margin-left: 4px; }
.form-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Cart ---------- */
.cart-list { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.cart-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.cart-item-main { font-size: 13px; }
.cart-item-sku { font-size: 11px; color: var(--ink-soft); }
.cart-item-opt { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.cart-item-price { font-size: 13px; font-weight: 600; white-space: nowrap; }
.cart-item-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; margin-left: 8px; }

.cart-summary { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.summary-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; color: var(--ink-soft); }
.summary-row.total { font-size: 16px; font-weight: 700; color: var(--ink); border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }

/* ---------- Footer ---------- */
.footer { text-align: center; font-size: 11px; color: #a7a293; padding: 20px 0 30px; letter-spacing: 0.04em; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(20,18,14,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-card {
  background: #fff; border-radius: 12px; max-width: 640px; width: 100%;
  max-height: 85vh; overflow-y: auto; padding: 24px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-body h3 { font-size: 14px; margin: 18px 0 8px; }
.modal-body p, .modal-body li { font-size: 13px; color: var(--ink-soft); }
.modal-body ul { padding-left: 20px; }
.modal-body code { background: #f1efe8; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.admin-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.admin-stats .stat { background: #faf9f5; border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; }
.admin-stats .stat .num { font-size: 20px; font-weight: 700; display: block; }
.admin-stats .stat .label { font-size: 11px; color: var(--ink-soft); }

/* ---------- Mobile (スマートフォン) ---------- */
@media (max-width: 640px) {
  /* iOSでinput focus時に自動ズームされるのを防ぐ（16px未満だとズームされる） */
  button, input, select, textarea { font-size: 16px; }

  .topbar { padding: 12px 14px; }
  .brand { flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; }
  .topbar-actions { width: 100%; justify-content: space-between; gap: 8px; }
  .fair-select { flex: 1; }
  .fair-select select { width: 100%; }

  .statusbar { padding: 10px 14px; flex-direction: column; align-items: stretch; gap: 8px; }
  .statusbar .status-left { flex-wrap: wrap; }
  .statusbar .btn-outline { width: 100%; }

  .layout { padding: 12px; gap: 12px; }
  .panel { padding: 12px; }

  .product-card { gap: 10px; }
  .product-thumb { width: 64px; height: 78px; }
  .product-topline { flex-wrap: wrap; row-gap: 4px; }
  .price-line { margin-left: 0; width: 100%; display: flex; justify-content: flex-end; gap: 8px; }

  .option-detail { flex-direction: column; gap: 14px; }
  .option-image { width: 100%; max-width: 260px; height: auto; aspect-ratio: 4 / 5; margin: 0 auto; }
  .option-main { min-width: 0; }

  .chip { padding: 9px 14px; }
  .btn { padding: 10px 14px; }
  .btn-small { padding: 8px 12px; }

  .cart-item { flex-direction: column; align-items: flex-start; gap: 6px; }
  .cart-item-remove { margin-left: 0; }

  .modal { padding: 10px; }
  .admin-header { padding: 12px 14px; }
  .admin-body-inner { padding: 14px; max-height: 72vh; }
  .admin-toolbar { flex-direction: column; align-items: stretch; }
  .admin-toolbar > div { flex-direction: column; align-items: stretch; }
  .admin-toolbar .btn { width: 100%; }
  .order-row { flex-direction: column; align-items: stretch; }
  .order-row-actions { justify-content: flex-start; }
}

/* ---------- Admin dashboard ---------- */
.admin-card { max-width: 1040px; padding: 0; }

.admin-login { padding: 44px 30px; max-width: 380px; margin: 0 auto; text-align: center; }
.admin-login .icon { font-size: 34px; margin-bottom: 6px; }
.admin-login h2 { font-size: 16px; margin: 4px 0 6px; }
.admin-login p.sub { font-size: 12px; color: var(--ink-soft); margin-bottom: 16px; }
.admin-pass-row { position: relative; margin-bottom: 12px; }
.admin-pass-row input { width: 100%; padding: 10px 40px 10px 12px; border: 1px solid var(--border); border-radius: 8px; text-align: center; }
.admin-pass-row button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: none; cursor: pointer; font-size: 14px; }
.admin-login .error-msg { color: var(--danger); font-size: 12px; margin-bottom: 8px; min-height: 16px; }
.security-note { text-align: left; background: #faf9f5; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 11px; color: var(--ink-soft); margin-top: 16px; line-height: 1.7; }
.security-note strong { color: var(--ink); }

.admin-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.admin-header h2 { margin: 0; font-size: 15px; }
.admin-header-actions { display: flex; gap: 8px; align-items: center; }

.admin-tabs { display: flex; border-bottom: 1px solid var(--border); overflow-x: auto; }
.admin-tab-btn { padding: 12px 16px; border: none; background: none; cursor: pointer; font-size: 13px; color: var(--ink-soft); border-bottom: 2px solid transparent; white-space: nowrap; }
.admin-tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.admin-tab-badge { background: #efece3; color: var(--ink-soft); font-size: 10px; padding: 1px 6px; border-radius: 10px; margin-left: 4px; }

.admin-body-inner { padding: 18px 20px; max-height: 65vh; overflow-y: auto; }

.admin-stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-stat-card { flex: 1; min-width: 130px; background: #faf9f5; border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.admin-stat-card.dark { background: var(--header); color: #f4f2ec; border-color: var(--header); }
.admin-stat-card .num { font-size: 22px; font-weight: 700; display: block; }
.admin-stat-card .label { font-size: 11px; color: var(--ink-soft); }
.admin-stat-card.dark .label { color: #cfcabf; }

.admin-toolbar { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.admin-search { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }

.customer-group { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.customer-group-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 8px; }
.customer-group-name { font-weight: 700; }
.customer-group-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.customer-group-total { text-align: right; font-weight: 700; }

.order-row { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding: 8px 0; gap: 8px; flex-wrap: wrap; }
.order-row-meta { font-size: 12px; color: var(--ink-soft); }
.order-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.order-row-actions button { font-size: 11px; padding: 4px 9px; }

.mask-toggle { cursor: pointer; color: var(--accent-dark); text-decoration: underline; font-size: inherit; }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th, .admin-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; white-space: nowrap; }
.admin-table th { background: #faf9f5; }

.danger-btn { background: #fbeceb; border-color: #e3b3ac; color: var(--danger); }
.danger-btn:hover { background: #f6d9d6; }

/* ---------- Order confirm popup ---------- */
.confirm-card { max-width: 460px; padding: 22px; }
.confirm-card h2 { font-size: 16px; margin: 0 0 4px; }
.confirm-meta { font-size: 12px; color: var(--ink-soft); margin-bottom: 14px; }
.confirm-items { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; margin-bottom: 14px; }
.confirm-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.confirm-item-name { font-size: 13px; font-weight: 600; }
.confirm-item-opt { font-size: 11px; color: var(--ink-soft); margin: 2px 0 6px; }
.confirm-price-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.confirm-price-list { color: var(--ink-soft); }
.confirm-price-list.struck { text-decoration: line-through; }
.confirm-price-discount { color: var(--accent-dark); font-weight: 700; font-size: 12px; }
.confirm-price-final { font-weight: 700; margin-left: auto; }
.confirm-totals { border-top: 1px solid var(--border); padding-top: 10px; margin-bottom: 16px; }
.confirm-totals .summary-row.total { font-size: 15px; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { flex: 1; }

/* ---------- Price list/discount badge (catalog, option, cart) ---------- */
.price-list-struck { font-size: 12px; color: var(--ink-soft); text-decoration: line-through; }
.price-off-badge { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; background: var(--accent-dark); padding: 1px 7px; border-radius: 10px; }
#cartDiscountBadge:not(:empty) { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; background: var(--accent-dark); padding: 2px 9px; border-radius: 10px; margin-left: 8px; vertical-align: middle; }

/* ---------- Channel gate (press/wholesale password lock) ---------- */
.gate-overlay {
  position: fixed; inset: 0; background: var(--header);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.gate-card { background: #fff; border-radius: 12px; padding: 40px 32px; max-width: 340px; width: 100%; text-align: center; }
.gate-icon { font-size: 32px; margin-bottom: 8px; }
.gate-card h2 { font-size: 16px; margin: 4px 0 4px; }
.gate-sub { font-size: 12px; color: var(--ink-soft); margin-bottom: 16px; }
.gate-pass-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; text-align: center; margin-bottom: 8px; }
.gate-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-bottom: 8px; }
