:root {
  --bg: #f6f5f2;            /* 温かみのあるクリーム */
  --card: #ffffff;
  --primary: #ab8d63;      /* ブランドゴールド（アクセント） */
  --primary-dark: #8a6a43; /* 濃いゴールド（白文字ボタン用） */
  --gold-soft: #f2ece1;    /* ゴールドの淡い面 */
  --in: #3f7d5a;           /* 入庫（落ち着いた緑） */
  --out: #c0473b;          /* 出庫（温かみのある赤） */
  --text: #231815;         /* 温かみのある濃茶（HP本文色） */
  --muted: #7c716a;
  --border: #e7e2da;       /* 温かみのある境界線 */
  --shadow: 0 1px 3px rgba(35,24,21,.07), 0 1px 2px rgba(35,24,21,.04);
  --serif: "Noto Serif JP", "Hiragino Mincho ProN", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 72px;
}

/* ヘッダー */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, #8a6a43, #7a5c39);
  color: #fff;
  padding: 13px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 10px rgba(35,24,21,.18);
}
/* ブランド表示 */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
  background: #fff; padding: 4px; object-fit: contain;
  box-shadow: 0 1px 3px rgba(35,24,21,.25);
}
.brand-title { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: .02em; }
.brand-title em { font-style: normal; font-weight: 500; opacity: .92; font-size: 15px; }
.badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.badge-local { background: rgba(255,255,255,.22); color: #fff; }
.badge-cloud { background: #dec663; color: #4a3a12; }

/* ビュー */
main { max-width: 720px; margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

/* スキャン */
.reader {
  width: 100%; aspect-ratio: 4/3; background: #0f172a;
  border-radius: 14px; overflow: hidden; margin-bottom: 12px;
}
.reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scan-controls { display: flex; gap: 10px; margin-bottom: 12px; }
.manual-input { display: flex; gap: 8px; margin-bottom: 16px; }
.manual-input input { flex: 1; }

/* ボタン */
.btn {
  border: none; border-radius: 12px; padding: 14px 18px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  transition: transform .05s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--primary-dark); color: #fff; flex: 1; }
.btn-ghost { background: #ece6dc; color: var(--text); }
.btn-in { background: var(--in); color: #fff; flex: 1; }
.btn-out { background: var(--out); color: #fff; flex: 1; }
.btn-step {
  background: #ece6dc; color: var(--text); width: 48px; padding: 12px 0;
  font-size: 22px; line-height: 1;
}

/* 入力 */
input {
  font-size: 16px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; width: 100%; background: #fff; color: var(--text);
}
input:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* スキャン結果 */
.scan-result { animation: pop .2s ease; }
@keyframes pop { from { transform: scale(.96); opacity: .5; } to { transform: scale(1); opacity: 1; } }
.product-card {
  background: var(--card); border-radius: 14px; padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.product-name { font-size: 20px; font-weight: 700; font-family: var(--serif); }
.product-jan { color: var(--muted); font-size: 14px; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.product-stock { font-size: 16px; }
.product-stock strong { font-size: 24px; color: var(--primary-dark); }
.qty-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.qty-row label { font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { width: 80px; text-align: center; font-size: 20px; font-weight: 700; }
.action-row { display: flex; gap: 10px; }
.unknown {
  margin-top: 14px; padding: 14px; background: #fef3c7;
  border-radius: 12px; border: 1px solid #fde68a;
}
.unknown p { margin: 0 0 10px; color: #78350f; font-weight: 600; }
.unknown input { margin-bottom: 10px; }

/* リスト */
.search-row { margin-bottom: 12px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--card); border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.li-name { font-weight: 700; font-size: 16px; }
.li-sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.li-stock { font-size: 22px; font-weight: 800; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.li-stock.zero { color: var(--out); }
.li-badge { font-weight: 800; font-size: 16px; padding: 4px 12px; border-radius: 999px; }
.li-badge.in { background: #d1fae5; color: var(--in); }
.li-badge.out { background: #fee2e2; color: var(--out); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* フォーム */
.form-card {
  background: var(--card); border-radius: 14px; padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.form-card h2 { margin: 0 0 8px; font-size: 18px; font-family: var(--serif); font-weight: 600; }
.form-card label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.form-card .btn { margin-top: 14px; }

/* タブバー */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; padding: 10px 0 8px;
  font-size: 11px; color: var(--muted); font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
}
.tab span { font-size: 22px; }
.tab.active { color: var(--primary-dark); }

/* トースト */
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; font-size: 14px; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  max-width: 90%; text-align: center;
}
.toast.error { background: var(--out); }

/* ---- 追加: カテゴリ / ロット / 有効期限 ---- */
.select {
  font-size: 16px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; width: 100%; background: #fff; color: var(--text);
}
.hint { font-size: 12px; color: var(--muted); margin: 10px 2px 0; line-height: 1.5; }

.product-meta { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.chip {
  background: var(--gold-soft); color: var(--primary-dark); font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}
.product-stock { font-size: 15px; }
.product-stock strong { font-size: 22px; color: var(--primary); }

.field-grid { display: flex; gap: 10px; margin-bottom: 12px; }
.field { flex: 1; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }

/* カテゴリフィルタ */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; }
.chip-btn {
  flex: 0 0 auto; border: 1px solid var(--border); background: #fff; color: var(--muted);
  font-size: 13px; font-weight: 700; padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.chip-btn.active { background: var(--primary-dark); color: #fff; border-color: var(--primary-dark); }

/* 在庫カード（ロット表示） */
.stock-card {
  background: var(--card); border-radius: 12px; padding: 14px 16px;
  box-shadow: var(--shadow); border-left: 4px solid transparent;
}
.stock-card.brd-near { border-left-color: #f59e0b; }
.stock-card.brd-expired { border-left-color: var(--out); }
.stock-head { display: flex; align-items: center; justify-content: space-between; }
.lots { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.lot-line { display: grid; grid-template-columns: 1fr auto 40px; align-items: center; gap: 8px; font-size: 13px; }
.lot-name { color: var(--text); font-weight: 600; }
.lot-qty { text-align: right; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.lot-exp { justify-self: end; }

.exp-badge {
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.exp-badge.exp-ok { background: #f1f5f9; color: var(--muted); }
.exp-badge.exp-near { background: #fef3c7; color: #92400e; }
.exp-badge.exp-expired { background: #fee2e2; color: #b91c1c; }
.exp-badge.exp-none { background: #f1f5f9; color: #94a3b8; }

/* ---- ログイン / モーダル ---- */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  overflow-y: auto;
}
.login-box, .modal-box {
  background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-box { max-width: 480px; max-height: 88vh; overflow-y: auto; }
.login-logo { display: block; width: 72px; height: 72px; margin: 0 auto 10px; }
.login-title { margin: 0; font-size: 24px; color: var(--primary-dark); text-align: center; font-family: var(--serif); font-weight: 600; }
.login-sub { text-align: center; color: var(--muted); margin: 4px 0 18px; font-size: 13px; }
.login-note { background: #fef3c7; color: #78350f; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 8px; }
.login-box label, .modal-box label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 0 4px; }
.btn-block { width: 100%; margin-top: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 19px; font-family: var(--serif); font-weight: 600; }
.icon-btn { border: none; background: #e2e8f0; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; cursor: pointer; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* ---- ヘッダー右 ---- */
.header-right { display: flex; align-items: center; gap: 10px; position: relative; }
.user-btn { background: rgba(255,255,255,.18); color: #fff; border: none; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; }
.user-menu {
  position: absolute; top: 40px; right: 0; background: #fff; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); overflow: hidden; z-index: 50; min-width: 180px;
}
.menu-item { display: block; width: 100%; text-align: left; border: none; background: none; padding: 13px 16px; font-size: 14px; color: var(--text); cursor: pointer; }
.menu-item:hover { background: #f1f5f9; }

/* ---- 写真 ---- */
.card-flex { display: flex; gap: 12px; align-items: flex-start; }
.card-body { flex: 1; min-width: 0; }
.product-photo { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.product-supplier { color: var(--muted); font-size: 13px; margin-top: 6px; }
.photo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.photo-preview { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.mi-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mi-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: 0 0 auto; }
.mi-thumb.ph { background: repeating-linear-gradient(45deg,#f1f5f9,#f1f5f9 6px,#e2e8f0 6px,#e2e8f0 12px); }
.master-item { cursor: pointer; }

/* ---- 印刷ボタン / 検索行 ---- */
.search-row { display: flex; gap: 8px; align-items: center; }
.search-row input { flex: 1; }
.btn-print { flex: 0 0 auto; white-space: nowrap; }

/* ---- 棚卸し ---- */
.sec-title { font-size: 15px; margin: 20px 2px 10px; color: var(--muted); }
.stocktake-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stocktake-foot { display: flex; gap: 10px; margin-top: 14px; position: sticky; bottom: 76px; }
.stocktake-foot .btn { flex: 1; }
.st-count { width: 92px; text-align: center; font-size: 18px; font-weight: 700; }
.take-item { cursor: pointer; }
.li-badge.adj { background: #e0e7ff; color: #4338ca; }
