/* 焼き菓子と珈琲 ハルツグ（デモ）在庫・発注の管理 */
/* 共通部品は ⑧（08-csv-slip）のクラス名のまま（.seg は ⑦）。:root の色の値だけ design.md §1 に替えた */
:root {
  --c-base: #F7F3EE;
  --c-surface: #FFFFFF;
  --c-soft: #EFE8DF;
  --c-desk: #E8E1D8;
  --c-main: #3E2F25;
  --c-accent: #9A4E12;
  --c-accent-dark: #7C3E0E;
  --c-text: #2B2420;
  --c-sub: #655A52;
  --c-line: #E2DAD0;
  --c-good: #2E6B47;
  --c-good-bg: #E8F0EA;
  --c-bad: #B3261E;
  --c-bad-bg: #FDEDEB;
  --c-warn-bg: #FFF3D6;
  --c-warn: #5C4300;
  --c-off-bg: #E8E1D8;
  --c-off: #4E5257;

  /* 状態の札（§1-2） */
  --st-ok-fg: #2E6B47; --st-ok-bg: #E8F0EA;
  --st-low-fg: #5C4300; --st-low-bg: #FFF3D6; --st-low-edge: #A87800;
  --st-out-fg: #FFFFFF; --st-out-bg: #B3261E;
  --st-wait-fg: #1F4E8C; --st-wait-bg: #E3EEFA;
  /* 増減（§1-3） */
  --d-plus: #1F4E8C;
  --d-minus: #B3261E;

  /* 紙面 */
  --p-ink: #1E2124;
  --p-sub: #555A60;
  --p-rule: #C9CCD1;
  --p-head: #EEF0F2;
  --p-seal: #B23A2E;

  --font-body: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
  --font-head: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", var(--font-body);

  --pad-x: 16px;
  --gap-block: 32px;
  --pad-card: 16px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(43, 36, 32, .06);
  --tabs-h: 72px; /* 貼り付いたタブの下に見出しが来るように */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-base);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.8;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--c-main); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--c-main); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 var(--pad-x); }
.sub { font-size: 14px; color: var(--c-sub); line-height: 1.6; }
.num { text-align: right; }
.ctr { text-align: center; }
svg { flex: none; }
[tabindex="-1"]:focus { outline: none; }
[tabindex="-1"]:focus-visible { outline: 3px solid var(--c-main); }
.card, .panel, .sec-title, #wait-card, [id^="h-"] { scroll-margin-top: var(--tabs-h); }
input, select { scroll-margin-top: calc(var(--tabs-h) + 40px); scroll-margin-bottom: 96px; }

/* ---------- TENKA LAB バー（作品例・デモ 共通） ---------- */
.tl-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  padding: 8px 16px;
  background: #1B2A41;
  color: #FFFFFF;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: .04em;
}
.tl-bar__text { margin: 0; }
.tl-bar strong { font-weight: 700; }
.tl-bar__back {
  flex: none;
  position: relative;
  color: #FFFFFF;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tl-bar__back:hover { color: #FFFFFF; text-decoration-thickness: 2px; }
.tl-bar__back::before { content: ""; position: absolute; inset: -15px -8px; }
.tl-bar__back::after { content: "→"; margin-left: 4px; }
.tl-bar__back:focus-visible { outline: 3px solid #FFFFFF; outline-offset: 2px; }
@media (min-width: 768px) {
  .tl-bar { padding: 8px 32px; }
}

/* ---------- ヘッダー ---------- */
.site-header { padding: 16px 0; border-bottom: 1px solid var(--c-line); }
.brand {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  font-size: 20px; font-weight: 700; line-height: 1.4; color: var(--c-main);
}
.brand__name { font-family: var(--font-head); }
.brand__logo { flex: none; }
.brand__demo {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
  background: var(--c-text); color: #fff; border-radius: 4px;
  font-family: var(--font-body); font-size: 12px; font-weight: 700; line-height: 1;
}
.brand__sub { margin-top: 4px; font-size: 14px; color: var(--c-sub); line-height: 1.6; }

main { padding-top: var(--gap-block); padding-bottom: var(--gap-block); }
main > * + * { margin-top: var(--gap-block); }

.sec-title { font-size: 18px; font-weight: 700; line-height: 1.4; color: var(--c-main); }

/* ---------- h1・リード・手順 ---------- */
.page-title { font-size: 22px; font-weight: 700; line-height: 1.4; color: var(--c-main); }
.intro__lead { margin-top: 12px; }
.steps { display: grid; gap: 8px; margin-top: 24px; }
.step a {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px;
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 8px;
  color: var(--c-text); text-decoration: none; font-size: 14px; font-weight: 700; line-height: 1.5;
}
.step a:hover { border-color: var(--c-main); }
.step__num {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; background: var(--c-main); color: #fff; font-size: 13px; font-weight: 700; line-height: 1;
}
.intro__notes { margin-top: 16px; font-size: 14px; color: var(--c-sub); line-height: 1.6; }

/* ---------- カード ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line); border-top: 4px solid var(--c-main);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--pad-card); min-width: 0;
}
.card__head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
  margin-bottom: 16px;
}
.card__head h2 { font-size: 18px; line-height: 1.4; color: var(--c-main); }
.card__head h3 { font-size: 16px; line-height: 1.5; color: var(--c-main); }
.card__link { margin-top: 24px; font-size: 14px; }

/* ---------- ボタン ---------- */
.btn-main {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 0 32px; border: 0; border-radius: 26px;
  background: var(--c-accent); color: #fff; font-size: 16px; font-weight: 700; line-height: 1.3; cursor: pointer;
}
.btn-main [data-icon], .btn-sub [data-icon] { display: inline-flex; }
.btn-main:hover, .btn-main:active { background: var(--c-accent-dark); }
.btn-sub {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border: 2px solid var(--c-main); border-radius: 24px;
  background: var(--c-surface); color: var(--c-main); font-size: 15px; font-weight: 700; line-height: 1.3; cursor: pointer;
}
.btn-sub:hover { background: var(--c-soft); }
[aria-disabled="true"].btn-main, [aria-disabled="true"].btn-sub {
  background: var(--c-off-bg); color: var(--c-off); border-color: var(--c-off-bg); cursor: not-allowed;
}
/* 小さい副ボタン（高さ 40px。::before で押せる範囲を 48px に） */
.btn-sm {
  position: relative; min-height: 40px; padding: 0 14px; border-width: 1.5px; border-radius: 20px;
  font-size: 14px; gap: 2px; white-space: nowrap;
}
.btn-sm::before { content: ""; position: absolute; inset: -5px -2px; }
.text-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 48px;
  color: var(--c-main); font-size: 15px; text-decoration: underline; text-underline-offset: 3px;
}
.dot-list li { position: relative; padding-left: 1em; }
.dot-list li::before { content: "・"; position: absolute; left: 0; }

/* ---------- 切替（⑦の .seg。色だけ §1） ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--c-line); border-radius: 24px; background: #FFFFFF; overflow: hidden; }
.seg__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 48px; padding: 0 6px; border: 0; background: #FFFFFF; color: var(--c-text);
  font-size: 15px; font-weight: 400; line-height: 1.3; cursor: pointer; text-align: center;
}
.seg__btn + .seg__btn { border-left: 1px solid var(--c-line); }
#f-cat .seg__btn, #c-cat .seg__btn { font-size: 14px; padding: 0 4px; }
.seg__btn[aria-pressed="true"], .seg__btn[aria-checked="true"] { background: var(--c-main); color: #FFFFFF; font-weight: 700; }
.seg__btn:hover:not([aria-pressed="true"]):not([aria-checked="true"]) { background: var(--c-soft); }
.seg__btn:focus-visible { outline-offset: -4px; outline-color: var(--c-main); }
.seg__btn[aria-pressed="true"]:focus-visible, .seg__btn[aria-checked="true"]:focus-visible { outline-color: #FFFFFF; }

/* ---------- 上の数字（§6） ---------- */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.summary__box {
  min-width: 0; min-height: 96px; padding: 12px 16px; background: var(--c-surface);
  border: 1px solid var(--c-line); border-radius: 12px; display: flex; flex-direction: column;
}
.summary__box--low { box-shadow: inset 4px 0 0 var(--st-low-edge); }
.summary__box--out { box-shadow: inset 4px 0 0 var(--c-bad); }
.summary__box--wait { box-shadow: inset 4px 0 0 var(--st-wait-fg); }
.summary__label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; line-height: 1.4; }
.summary__icon { display: inline-flex; }
.summary__box--low .summary__icon { color: var(--st-low-fg); }
.summary__box--out .summary__icon { color: var(--c-bad); }
.summary__box--wait .summary__icon { color: var(--st-wait-fg); }
.summary__val { margin-top: 4px; line-height: 1.2; }
.summary__n { font-size: 28px; font-weight: 700; }
.summary__n--yen { font-size: 24px; }
.summary__unit { margin-left: 4px; font-size: 14px; color: var(--c-sub); }
.summary__link { margin-top: auto; font-size: 14px; line-height: 1.4; }
.summary__link a { position: relative; display: inline-flex; align-items: center; min-height: 32px; font-weight: 700; text-underline-offset: 3px; }
.summary__link a::before { content: ""; position: absolute; inset: -8px -6px; }
.summary__note { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--c-sub); line-height: 1.4; }

/* ---------- タブ（§7） ---------- */
.tabs {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 4px;
  background: var(--c-base); border-bottom: 1px solid var(--c-line);
}
.tabs__tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  min-height: 52px; padding: 4px 6px; border: 0; border-radius: 8px 8px 0 0; background: transparent;
  color: var(--c-sub); font-size: 15px; font-weight: 700; line-height: 1.3; text-align: center; cursor: pointer;
  box-shadow: inset 0 -4px 0 transparent;
}
.tabs__tab:hover { background: var(--c-soft); }
.tabs__tab[aria-selected="true"] { color: var(--c-main); background: var(--c-surface); box-shadow: inset 0 -4px 0 var(--c-main); }
.tabs__tab:focus-visible { outline-offset: -3px; }
.tabs__badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--c-main); color: #FFFFFF; font-size: 12px; font-weight: 700; line-height: 1;
}
.panel { padding-top: 24px; }
.panel > * + * { margin-top: 24px; }

/* ---------- 状態の札（§1-2）・種類の札・増減 ---------- */
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.state {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px 0 8px;
  border: 1px solid transparent; font-size: 13px; font-weight: 700; line-height: 1; white-space: nowrap;
}
.state[data-state="ok"] { background: var(--st-ok-bg); color: var(--st-ok-fg); border-color: var(--st-ok-fg); border-radius: 14px; }
.state[data-state="low"] { background: var(--st-low-bg); color: var(--st-low-fg); border-color: var(--st-low-fg); border-radius: 4px; }
.state[data-state="out"] { background: var(--st-out-bg); color: var(--st-out-fg); border-color: var(--st-out-bg); border-radius: 4px; }
.state[data-wait="1"] { background: var(--st-wait-bg); color: var(--st-wait-fg); border: 1px dotted var(--st-wait-fg); border-radius: 14px; }
.kind {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  background: var(--c-soft); color: var(--c-main); border-radius: 4px; font-size: 13px; font-weight: 700; line-height: 1; white-space: nowrap;
}
.delta { font-weight: 700; white-space: nowrap; }
.d-plus { color: var(--d-plus); }
.d-minus { color: var(--d-minus); }
.d-zero { color: var(--c-sub); }
.is-neg { color: var(--c-bad); }
.nw { white-space: nowrap; }

/* ---------- 入力 ---------- */
.field + .field { margin-top: 16px; }
.field__label { display: block; margin-bottom: 6px; font-size: 15px; font-weight: 700; line-height: 1.4; }
.field__hint { margin-top: 6px; font-size: 13px; color: var(--c-sub); line-height: 1.5; }
.field__err { margin-top: 6px; font-size: 14px; font-weight: 700; color: var(--c-bad); line-height: 1.5; }
.select, .input {
  display: block; width: 100%; min-height: 48px; padding: 0 12px; border: 1.5px solid var(--c-sub); border-radius: 8px;
  background: #FFFFFF; font-size: 16px; line-height: 1.4;
}
.select { padding-right: 36px; appearance: none; -webkit-appearance: none;
  background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%233E2F25' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 16px 16px;
}
.input[aria-invalid="true"] { border: 2px solid var(--c-bad); }
.qty-box { position: relative; }
.input--qty { padding-right: 48px; }
.qty-box__unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; color: var(--c-sub); pointer-events: none; }
.input--num { width: 96px; text-align: right; flex: none; }

/* ---------- 記録する（§8） ---------- */
.rec__now { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 8px; font-size: 14px; color: var(--c-sub); line-height: 1.6; }
.rec__now strong { color: var(--c-text); }
#rec-kind .seg__btn svg { width: 16px; height: 16px; }
.rec__after {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 16px; padding: 12px 16px;
  background: var(--c-soft); border-radius: 8px; font-size: 15px; line-height: 1.5;
}
.rec__after.is-minus { background: var(--c-bad-bg); color: var(--c-bad); font-weight: 700; }
.rec__btn { margin-top: 16px; }

/* ---------- 在庫一覧（§9） ---------- */
.filters { display: grid; gap: 8px; }
.yen-box { margin: 16px 0; padding: 12px 16px; background: var(--c-soft); border-radius: 8px; }
.yen-box__l1 { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; font-size: 14px; font-weight: 700; line-height: 1.5; }
.yen-box__total { font-size: 20px; }
.yen-box__shown { font-size: 14px; line-height: 1.5; }
.yen-box__note { margin-top: 4px; font-size: 13px; color: var(--c-sub); line-height: 1.5; }
.empty { padding: 24px; background: var(--c-base); border-radius: 8px; font-size: 15px; text-align: center; }

.stock { display: none; }
.stock-list { display: grid; gap: 8px; }
/* スマホのカード：左に「札／品目名／在庫と発注点」の3段、右に記録ボタン（§23-1） */
.stock-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 4px; align-items: center;
  padding: 10px 12px 10px 16px; background: var(--c-surface);
  border: 1px solid var(--c-line); border-radius: 8px; line-height: 1.4;
}
.stock-list li[data-state="low"] { box-shadow: inset 4px 0 0 var(--st-low-edge); }
.stock-list li[data-state="out"] { box-shadow: inset 4px 0 0 var(--c-bad); }
.stock-list li > .tags { grid-column: 1; grid-row: 1; }
.stock-list__name { grid-column: 1; grid-row: 2; margin-top: 0; font-size: 16px; font-weight: 700; }
.stock-list__sub { display: none; }
.stock-list__q { grid-column: 1; grid-row: 3; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 16px; }
.stock-list__q .lbl { font-size: 13px; color: var(--c-sub); }
.stock-list__q strong { font-size: 18px; }
.stock-list__q .rop { font-size: 15px; }
.stock-list__foot { display: contents; font-size: 14px; }
.stock-list__foot > span { display: none; }
.stock-list__foot > .btn-sm { grid-column: 2; grid-row: 1 / 4; align-self: center; justify-self: end; padding: 0 10px; }  /* 360px で在庫・発注点を1行に収めるため、表と同じ内側 10px に（幅 約 66px） */
/* 品目名を括弧の前でだけ折り返す（§23-2） */
.nm-seg { display: inline-block; max-width: 100%; }
.is-flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background-color: #FFF3D6; } to { background-color: #FFFFFF; } }
.stock tr.is-flash > * { animation: flash 1.2s ease-out; }

/* ---------- 履歴（§10） ---------- */
.hist__count { margin-left: 4px; font-size: 14px; font-weight: 400; color: var(--c-sub); }
.card__head h2 .hist__count { font-size: 14px; }
.hist__lead { margin-top: -8px; margin-bottom: 12px; }
.hist-table { display: none; }
.hist-list { border-top: 1px solid var(--c-line); }
.hist-list li { padding: 12px 0; border-bottom: 1px solid var(--c-line); }
.hist-list__l1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hist-list .hist__at { font-size: 13px; color: var(--c-sub); }
.hist-list__l2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; margin-top: 4px; font-size: 15px; line-height: 1.5; }
.hist-list__l2 .hist__name { font-weight: 700; }
.hist-list__q { white-space: nowrap; }
.hist-list__q .hist__after { font-weight: 700; }
.hist-list__l3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; min-height: 0; }
.hist-list__l3:has(button) { min-height: 48px; }
.hist-list .hist__memo { font-size: 14px; line-height: 1.5; }
.hist__done { font-size: 13px; color: var(--c-sub); white-space: nowrap; }
.hist__more { width: 100%; margin-top: 16px; }

/* ---------- 発注リスト（§11） ---------- */
.order-head .sub { margin-top: 4px; }
.order-sum { display: grid; gap: 12px; }
.order-sum__text { padding: 12px 16px; background: var(--c-soft); border-radius: 8px; font-size: 15px; line-height: 1.6; }
.order-sum__text strong { font-size: 18px; }
.order-sum__note { margin-top: 8px; font-size: 13px; color: var(--c-sub); line-height: 1.6; }
#order-area > * + * { margin-top: 24px; }
.order-card__head { display: grid; gap: 12px; }
.order-card__title h3 { font-size: 16px; line-height: 1.5; color: var(--c-main); }
.order-card__meta { font-size: 14px; line-height: 1.5; }
.order-card__ops { display: grid; gap: 8px; order: 2; }
.order-card { display: flex; flex-direction: column; gap: 12px; }
.order-card .order { order: 1; }
.order-card__head { display: contents; }
.order-card__title { order: 0; }

/* スマホ・タブレット：品目ごとに4段（表の要素を縦に組み替える） */
.order, .order tbody, .order tr, .order th, .order td { display: block; }
.order thead, .order colgroup, .order caption { display: none; }
.order { border-top: 1px solid var(--c-line); }
.order tr { padding: 12px 0; border-bottom: 1px solid var(--c-line); }
.order th { text-align: left; font-weight: 400; }
.order__nm { display: block; font-size: 16px; font-weight: 700; line-height: 1.4; }
.order__spmeta { display: block; margin-top: 2px; font-size: 13px; color: var(--c-sub); line-height: 1.5; }
.order__pc { display: none !important; }
.order__in { margin-top: 8px; }
.order__inrow { display: flex; align-items: center; gap: 8px; }
.order__unit { font-size: 14px; color: var(--c-sub); }
.order__yen { margin-left: auto; font-size: 15px; font-weight: 700; }
.order__f { margin-top: 6px; font-size: 12px; color: var(--c-sub); line-height: 1.5; }
.order__mark { margin-left: 4px; font-size: 13px; font-weight: 700; color: var(--c-warn); }
.order tr.is-zero .order__nm, .order tr.is-zero .order__yen, .order tr.is-zero td { color: var(--c-sub); }
.order-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px;
  background: var(--c-base); border: 2px dashed var(--c-line); border-radius: 8px; text-align: center; color: var(--c-good);
}
.order-empty__title { font-size: 16px; font-weight: 700; color: var(--c-text); }
.order-empty__text { font-size: 14px; color: var(--c-text); }

.wait-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--c-line); }
.wait-list li > .state { grid-column: 1 / -1; justify-self: start; }
.wait-list__name { font-size: 15px; font-weight: 700; line-height: 1.4; }
.wait-list__meta { font-size: 13px; color: var(--c-sub); line-height: 1.5; }
.wait-list__q { font-size: 15px; font-weight: 700; text-align: right; }
.wait-list li > .btn-sm { grid-column: 1 / -1; justify-self: start; margin-top: 4px; }

/* ---------- 棚卸（§12） ---------- */
.filters--count { margin-top: 16px; }
.count__status { margin-top: 12px; font-size: 14px; line-height: 1.6; }
#count-area { margin-top: 12px; }
.count-table, .count-table tbody, .count-table th, .count-table td { display: block; }
.count-table thead, .count-table colgroup { display: none; }
.count-table { border-top: 1px solid var(--c-line); }
.count-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 12px 0; border-bottom: 1px solid var(--c-line); }
.count-table th { flex-basis: 100%; text-align: left; }
.count__nm { display: block; font-size: 16px; font-weight: 700; line-height: 1.4; }
.count__sub { display: block; font-size: 13px; font-weight: 400; color: var(--c-sub); line-height: 1.5; }
.count__b { flex-basis: 100%; text-align: left; font-size: 15px; }
.sp-lbl { font-size: 13px; color: var(--c-sub); }
.count__in { flex-basis: 100%; margin-top: 4px; }
.count__dc, .count__rc { font-size: 15px; text-align: left; }
.count__r { font-size: 15px; }
.count__r:not(:empty)::before { content: "（"; }
.count__r:not(:empty)::after { content: "）"; }
.count-table tr:not(.has-val) .count__dc, .count-table tr:not(.has-val) .count__rc, .count-table tr:not(.has-val) .count__mc { display: none; }
.count__mc { flex-basis: 100%; }
.count__mc:empty { display: none; }
.bigmark {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px;
  background: var(--c-warn-bg); color: var(--c-warn); border: 1px solid var(--c-warn); border-radius: 4px;
  font-size: 13px; font-weight: 700; line-height: 1; white-space: nowrap;
}
.count__ops { display: grid; gap: 12px; margin-top: 24px; }
.count__off { margin-top: 8px; font-size: 13px; }

/* ---------- 最初の状態に戻す ---------- */
.reset-btn { width: 100%; }

/* ---------- 実際のお仕事では ---------- */
.work-boxes { display: grid; gap: 16px; margin-top: 24px; }
.work-box { padding: 20px; background: var(--c-base); border: 1px solid var(--c-line); border-radius: 8px; }
.work-box h3 { margin-top: 8px; font-size: 16px; line-height: 1.5; }
.work-box .dot-list { margin-top: 8px; font-size: 15px; line-height: 1.7; }
.work-safe { margin-top: 16px; font-size: 14px; line-height: 1.6; }

/* ---------- 確認の窓（§13-4） ---------- */
.confirm {
  width: min(480px, calc(100% - 32px)); max-width: none; padding: 24px; border: 0; border-top: 4px solid var(--c-main);
  border-radius: 12px; background: #FFFFFF; color: var(--c-text);
}
.confirm::backdrop { background: rgba(43, 36, 32, .5); }
.confirm__title { font-size: 18px; font-weight: 700; color: var(--c-main); line-height: 1.4; }
.confirm__body { margin-top: 12px; font-size: 15px; line-height: 1.7; }
.confirm__list { margin-top: 8px; font-size: 14px; line-height: 1.6; }
.confirm__list li { position: relative; padding-left: 1em; }
.confirm__list li::before { content: "・"; position: absolute; left: 0; }
.confirm__ops { display: grid; gap: 8px; margin-top: 24px; }
.confirm__cancel {
  min-height: 48px; padding: 0 16px; border: 0; background: none; color: var(--c-main);
  font-size: 15px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ---------- 知らせ ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: min(480px, calc(100% - 32px));
  padding: 12px 16px; background: var(--c-text); color: #fff; border-radius: 8px; font-size: 15px; line-height: 1.5;
}
.toast.is-in { animation: toast-in 200ms ease-out both; }
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------- フッター ---------- */
.site-footer {
  background: var(--c-text); color: var(--c-base); font-size: 15px; line-height: 1.8;
  padding: 48px 16px; text-align: center;
}
.site-footer p + p { margin-top: 16px; }
.site-footer :focus-visible { outline-color: #FFFFFF; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; max-width: 100%; min-height: 52px;
  margin: 0 auto; border-radius: 26px; background: var(--c-accent); color: #fff;
  font-size: 16px; font-weight: 700; text-decoration: none;
}
.btn:hover, .btn:active { background: var(--c-accent-dark); }
.copy { font-size: 12px; }

#print-root { display: none; }

@media (prefers-reduced-motion: reduce) {
  .toast.is-in, .is-flash, .stock tr.is-flash > * { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- 768px 以上 ---------- */
@media (min-width: 768px) {
  :root { --pad-x: 32px; --gap-block: 48px; --pad-card: 24px; }
  .site-header { padding: 24px 0; }
  .brand { font-size: 22px; }
  .page-title { font-size: 28px; }
  .sec-title, .card__head h2 { font-size: 20px; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
  .step a { min-height: 56px; }
  .summary { grid-template-columns: 1fr 1fr 1fr 1.4fr; gap: 16px; }
  .summary__box { padding: 16px 20px; }
  .summary__label { font-size: 14px; }
  .summary__n { font-size: 32px; }
  .tabs { justify-content: flex-start; }
  .tabs__tab { flex: none; padding: 0 16px; font-size: 16px; flex-wrap: nowrap; }
  .filters { display: flex; flex-wrap: wrap; gap: 8px 16px; }
  .filters .seg__btn, #f-cat .seg__btn, #c-cat .seg__btn { padding: 0 16px; font-size: 15px; white-space: nowrap; }
  .filters--count { grid-template-columns: auto; }

  /* 在庫一覧：表 */
  .stock-list { display: none; }
  .stock { display: table; width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
  .stock .c-st { width: 112px; }
  .stock .c-q { width: 80px; }
  .stock .c-rop { width: 72px; }
  .stock .c-yen { width: 80px; }
  .stock .c-op { width: 76px; }
  .stock thead th { height: 40px; padding: 0 8px; background: var(--c-soft); color: var(--c-sub); font-size: 13px; font-weight: 700; text-align: left; }
  .stock thead th.num { text-align: right; }
  .stock td, .stock tbody th { height: 56px; padding: 8px; border-bottom: 1px solid var(--c-line); vertical-align: middle; text-align: left; }
  .stock td.num { text-align: right; }
  .stock td.ctr { text-align: center; padding: 8px 2px; }
  .stock tbody th { font-weight: 400; }
  .stock tr[data-state="low"] > :first-child { box-shadow: inset 4px 0 0 var(--st-low-edge); }
  .stock tr[data-state="out"] > :first-child { box-shadow: inset 4px 0 0 var(--c-bad); }
  .stock td:first-child { padding-left: 12px; }
  .stock .tags { flex-direction: column; align-items: flex-start; }
  .stock__name { display: block; font-size: 15px; font-weight: 700; line-height: 1.4; }
  .stock__sub { display: block; font-size: 13px; color: var(--c-sub); line-height: 1.4; }
  .stock__q { font-size: 16px; font-weight: 700; }
  .stock .btn-sm { padding: 0 10px; }

  /* 棚卸：表 */
  .count-table { display: table; width: 100%; table-layout: fixed; border-collapse: collapse; border-top: 0; font-size: 15px; line-height: 1.5; }
  .count-table thead { display: table-header-group; }
  .count-table colgroup { display: table-column-group; }
  .count-table tbody { display: table-row-group; }
  .count-table tr { display: table-row; }
  .count-table th, .count-table td { display: table-cell; padding: 8px; border-bottom: 1px solid var(--c-line); vertical-align: middle; text-align: left; }
  .count-table thead th { height: 40px; background: var(--c-soft); color: var(--c-sub); font-size: 13px; font-weight: 700; }
  .count-table th.num, .count-table td.num { text-align: right; }
  .count-table tbody th { font-weight: 400; }
  .count-table .c-b { width: 88px; }
  .count-table .c-in { width: 148px; }
  .count-table .c-d { width: 88px; }
  .count-table .c-r { width: 76px; }
  .count-table .c-m { width: 136px; }
  .count-table tr:not(.has-val) .count__dc, .count-table tr:not(.has-val) .count__rc, .count-table tr:not(.has-val) .count__mc, .count__mc:empty { display: table-cell; }
  .count__in { margin-top: 0; }
  .count-table td { height: 56px; }
  .sp-lbl { display: none; }
  .count__r:not(:empty)::before, .count__r:not(:empty)::after { content: none; }
  .count__ops { grid-template-columns: 280px auto; justify-content: start; align-items: center; }

  .order-sum { grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 16px; }
  .order-sum__ops { width: 400px; }
  .order-sum__btn { white-space: nowrap; padding: 0 24px; }
  .order-card__ops { grid-template-columns: auto auto; justify-content: start; }
  .wait-list li { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .wait-list li > .state, .wait-list li > .btn-sm { grid-column: auto; margin-top: 0; }

  .hist__more { width: auto; }
  .reset-btn { width: 240px; }
  .confirm__ops { display: flex; flex-direction: row-reverse; justify-content: flex-start; align-items: center; gap: 8px; }
  .work-boxes { grid-template-columns: 1fr 1fr; gap: 24px; }
  .btn { width: 280px; }
}

/* ---------- 1024px 以上 ---------- */
@media (min-width: 1024px) {
  .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
  .step { position: relative; }
  .step + .step::before {
    content: ""; position: absolute; left: -20px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h11M9 4l4 4-4 4' fill='none' stroke='%23655A52' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 16px 16px;
  }

  /* 発注リスト：表 */
  .order-card { display: block; }
  .order-card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
  .order-card__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
  .order { display: table; width: 100%; table-layout: fixed; border-collapse: collapse; border-top: 0; font-size: 15px; line-height: 1.5; }
  .order thead { display: table-header-group; }
  .order colgroup { display: table-column-group; }
  .order tbody { display: table-row-group; }
  .order tr { display: table-row; padding: 0; }
  .order th, .order td { display: table-cell; padding: 8px; border-bottom: 1px solid var(--c-line); vertical-align: top; }
  .order thead th { height: 40px; vertical-align: middle; background: var(--c-soft); color: var(--c-sub); font-size: 13px; font-weight: 700; text-align: left; }
  .order thead th.num { text-align: right; }
  .order td.num { padding-top: 20px; }
  .order tbody th { padding-top: 18px; }
  .order .c-q { width: 88px; }
  .order .c-t { width: 80px; }
  .order .c-in { width: 200px; }
  .order .c-p { width: 88px; }
  .order .c-yen { width: 104px; }
  .order__pc { display: table-cell !important; }
  .order__spmeta, .order__yen { display: none; }
  .order__in { margin-top: 0; }
  .order__nm { font-size: 15px; }
  .order__yen-pc { font-weight: 700; }

  /* 履歴：表 */
  .hist-list { display: none; }
  .hist-table { display: table; width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
  .hist-table .c-at { width: 168px; }
  .hist-table .c-kind { width: 112px; }
  .hist-table .c-d { width: 96px; }
  .hist-table .c-after { width: 112px; }
  .hist-table .c-memo { width: 180px; }
  .hist-table .c-undo { width: 112px; }
  .hist-table thead th { height: 40px; padding: 0 8px; background: var(--c-soft); color: var(--c-sub); font-size: 13px; font-weight: 700; text-align: left; }
  .hist-table thead th.num { text-align: right; }
  .hist-table thead th.ctr { text-align: center; }
  .hist-table td, .hist-table tbody th { height: 56px; padding: 8px; border-bottom: 1px solid var(--c-line); vertical-align: middle; text-align: left; }
  .hist-table td.num { text-align: right; }
  .hist-table td.ctr { text-align: center; }
  .hist-table .hist__at { font-size: 14px; }
  .hist-table .hist__name { font-size: 15px; font-weight: 700; }
  .hist-table .hist__after { font-weight: 700; }
  .hist-table .hist__memo { font-size: 14px; }
  .hist-table .hist__memo.is-none { color: var(--c-sub); }
}

/* ---------- 1200px 以上：記録のカードを左に（§4-2） ---------- */
@media (min-width: 1200px) {
  .rec-grid { display: grid; grid-template-columns: 352px minmax(0, 1fr); gap: 32px; align-items: start; }
  .rec { position: sticky; top: 72px; }
}
.rec-grid > * + * { margin-top: 24px; }
@media (min-width: 1200px) { .rec-grid > * + * { margin-top: 0; } }

/* ---------- 印刷（A4 縦・1仕入先1ページ。§17） ---------- */
@page { size: A4 portrait; margin: 14mm 16mm; }

@media print {
  html, body { background: #FFFFFF !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root .print-empty { font-size: 12pt; }
  #print-root .po {
    color: #000000; font-size: 9.5pt; line-height: 1.5;
    break-after: page;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  #print-root .po:last-child { break-after: auto; }
  #print-root thead { display: table-header-group; }
  #print-root tr, #print-root .po-total, #print-root .po-foot { break-inside: avoid; }
  .po table { border-collapse: collapse; }
  .po-title {
    width: 50mm; margin: 0 auto 10pt; text-align: center; font-family: var(--font-head);
    font-size: 18pt; font-weight: 700; letter-spacing: .5em; padding-left: .5em; line-height: 1.6;
    border-bottom: 3px double var(--p-ink);
  }
  .po-meta { width: max-content; margin-left: auto; font-size: 10pt; text-align: right; }
  .po-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; margin-top: 10pt; }
  .po-to__name { padding-bottom: 3pt; border-bottom: 1.5px solid var(--p-ink); line-height: 1.5; }
  .po-to__co { font-family: var(--font-head); font-size: 14pt; font-weight: 700; }
  .po-to__hon { margin-left: 1em; font-size: 11pt; white-space: nowrap; }
  .po-to__lead { margin-top: 10pt; font-size: 9.5pt; }
  .po-from { font-size: 9pt; line-height: 1.7; text-align: right; }
  .po-from__name { position: relative; display: inline-block; padding-right: 17mm; font-size: 12pt; font-weight: 700; line-height: 1.5; text-align: right; }
  .po .stamp {
    position: absolute; top: -2mm; right: 0; width: 15mm; height: 15mm; transform: rotate(-4deg); opacity: .9;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .po-items { width: 100%; margin-top: 14pt; table-layout: fixed; }
  .po-w-no { width: 10mm; }
  .po-w-q { width: 22mm; }
  .po-w-u { width: 14mm; }
  .po-w-p { width: 24mm; }
  .po-w-a { width: 28mm; }
  .po-items th {
    padding: 3pt 5pt; background: var(--p-head); font-size: 9pt; text-align: left;
    border-top: 1.5px solid var(--p-ink); border-bottom: 1.5px solid var(--p-ink);
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .po-items th.num, .po-items td.num { text-align: right; }
  .po-items th.ctr, .po-items td.ctr { text-align: center; }
  .po-items td { height: 8mm; padding: 3pt 5pt; border-bottom: 1px solid var(--p-rule); font-size: 9.5pt; vertical-align: middle; }
  .po-items tbody tr:last-child td { border-bottom: 1.5px solid var(--p-ink); }
  .po-total { width: 60%; margin: 10pt 0 0 auto; border: 1.5px solid var(--p-ink); }
  .po-total th { background: var(--p-head); padding: 4pt 8pt; font-size: 9.5pt; text-align: left; white-space: nowrap; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .po-total td { padding: 4pt 8pt; text-align: right; font-family: var(--font-head); font-size: 16pt; font-weight: 700; }
  .po-note { margin-top: 4pt; font-size: 8pt; color: var(--p-sub); }
  .po-remarks { height: 24mm; margin-top: 12pt; padding: 4pt 8pt; border: 1px solid var(--p-ink); }
  .po-remarks__label { font-size: 9pt; font-weight: 700; color: var(--p-sub); }
  .po-foot { margin-top: 14pt; padding-top: 6pt; border-top: 1px solid var(--p-rule); font-size: 8pt; color: var(--p-sub); text-align: center; }
}
