/* 共通の見た目(色・文字・部品)。元になったデザインは 在庫管理デザイン.html と design/一覧デザインv2.html */

:root {
  /* 色 */
  --bg: #FBF9F4;           /* 背景 */
  --surface: #fff;         /* 白いカード */
  --surface-2: #F5F1EB;    /* 表の見出し・合計の枠・押したとき */
  --surface-3: #F1EDE7;    /* 分類の札・× ボタン */
  --seg: #EFEBE4;          /* 切り替えの溝 */
  --text: #3D3530;         /* 文字 */
  --sub: #7A716A;          /* 補足の文字 */
  --sub-2: #6B635C;        /* 少し弱い文字 */
  --sub-3: #5A524C;        /* 分類の札の文字 */
  --faint: #9A9089;        /* アイコン・区切り */
  --line: #E2DBD1;         /* 入力欄・ボタンの枠 */
  --line-soft: #ECE6DD;    /* メニューの境目・カードの影 */
  --line-row: #F2EDE6;     /* 表の行の境目 */
  --line-strong: #D9D1C6;  /* 書き出し・2番目のボタンの枠 */
  --dash: #B3A99D;         /* 直接修正できる数字の点線 */
  --green-bg: #D6EFE4;     /* 強調の緑(背景) */
  --green-text: #1E4A3F;   /* 強調の緑(文字) */
  --green-icon: #2E5E52;   /* いま開いているタブの印 */
  --link: #2E6B5E;         /* リンク */
  --link-line: #A9CFC3;    /* リンクの下線 */
  --primary: #A8DCC8;      /* 主なボタン */
  --ok-bg: #EEEBE6;   --ok-text: #6B635C;   --ok-dot: #B5ADA5;   /* 適正 */
  --low-bg: #F6A04D;  --low-text: #4A2600;                       /* 要発注 */
  --out-bg: #D2412E;  --out-text: #fff;                          /* 在庫切れ */
  --error: #B8321F;
  --shadow-pop: 0 10px 30px rgba(42, 37, 34, .18);
  --shadow-knob: 0 1px 3px rgba(61, 53, 48, .12);

  /* 文字 */
  --font: "Zen Maru Gothic", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 72px 16px 40px; /* 上は右上の三本線ボタンの分を空ける */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}
a { color: var(--link); }
a:hover { color: var(--green-text); }
button, input, select { font: inherit; color: inherit; }
input::placeholder { color: var(--faint); }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
hr { display: none; }

/* 画面の枠:どの画面も同じ幅・同じ左端にそろえる。中身の幅を狭めたいときは左寄せのまま狭める */
.page { max-width: 1280px; margin: 0 auto; }
.page > h1 { margin: 0 4px 16px; }
.narrow { max-width: 960px; }
.form-width { max-width: 560px; }

/* 来た道 */
.crumb { margin: 12px 4px 10px; font-size: 13px; }
.crumb ol { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
.crumb li { font-weight: 700; }
.crumb li + li::before { content: "＞"; margin-right: 8px; color: var(--faint); font-weight: 400; }
.crumb a { text-decoration: underline; text-underline-offset: 3px; }

/* 見出し */
h1 { margin: 0; font-size: 24px; font-weight: 900; }

/* 白い枠のボタン(書き出しなど) */
.btn-outline {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 14px;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 16px;
  font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.btn-outline small { font-size: 10px; font-weight: 400; color: var(--sub); }
.btn-outline:hover { background: var(--surface-2); }

/* 主なボタン(緑) */
.btn-primary {
  height: 50px; padding: 0 24px;
  background: var(--primary); color: var(--green-text);
  border: 0; border-radius: 16px; font-size: 15px; font-weight: 900; cursor: pointer;
}

/* 検索欄 */
.search {
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 6px 0 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px;
}
.search:focus-within { border-color: var(--link); box-shadow: 0 0 0 3px var(--green-bg); }
.search::before {
  content: ""; flex-shrink: 0;
  width: 14px; height: 14px; border: 2px solid var(--faint); border-radius: 99px;
}
.search input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text);
}
.search input::-webkit-search-cancel-button { display: none; }
.search .clear {
  flex-shrink: 0; width: 36px; height: 36px;
  border: 0; border-radius: 12px; background: var(--surface-3); color: var(--sub-2); font-size: 16px; cursor: pointer;
}

/* 丸い絞り込みボタン */
.chips { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 4px; }
.chip {
  display: flex; align-items: center; gap: 4px;
  height: 40px; padding: 0 10px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 99px;
  font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip .n { font-weight: 500; color: var(--sub); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .8; }
.dot { width: 8px; height: 8px; border-radius: 99px; }
.dot.ok { background: var(--ok-dot); } .dot.low { background: var(--low-bg); } .dot.out { background: var(--out-bg); }

/* 選ぶメニュー(並べ替え・分類) */
.menu { position: relative; min-width: 0; }
.menu-btn {
  width: 100%; height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px;
  font-size: 13px; cursor: pointer;
}
.menu-btn > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn .label { color: var(--sub); }
.menu-btn::after { content: "▾"; color: var(--faint); }
.menu-list {
  position: absolute; top: 50px; left: 0; z-index: 5;
  min-width: 100%; width: max-content;
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop);
}
.menu-list[hidden] { display: none; }
.menu-list button {
  height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 12px;
  background: transparent; border: 0; border-radius: 12px;
  font-size: 14px; text-align: left; cursor: pointer;
}
.menu-list button:hover { background: var(--surface-2); }
.menu-list button[aria-checked="true"]::after { content: "✓"; color: var(--link); font-weight: 900; }
.menu.right .menu-list { left: auto; right: 0; }

/* 2つから選ぶ切り替え(カード/表) */
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  width: 124px; padding: 3px;
  background: var(--seg); border-radius: 14px;
}
.seg button {
  height: 38px; background: transparent; border: 0; border-radius: 11px;
  font-size: 13px; color: var(--sub-2); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow-knob); cursor: default; }

/* 状態の札(色だけでなく必ず文字も出す) */
.badge { display: inline-block; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.low { background: var(--low-bg); color: var(--low-text); }
.badge.out { background: var(--out-bg); color: var(--out-text); }

/* 分類の小さな札 */
.tag { padding: 2px 8px; border-radius: 8px; background: var(--surface-3); color: var(--sub-3); font-weight: 700; }

/* 品目名のリンク */
.name { font-weight: 900; color: var(--link); text-decoration: underline; text-decoration-color: var(--link-line); text-underline-offset: 4px; }

/* 直接修正できる数字(点線の枠) */
.qty {
  width: 100%; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1.5px dashed var(--dash); border-radius: 12px;
  font-size: 18px; font-weight: 900; cursor: pointer;
}
.qty:hover { border-color: var(--link); background: var(--surface-2); }
.qty-input {
  width: 100%; height: 42px; padding: 0 6px;
  border: 2px solid var(--link); border-radius: 12px; background: var(--surface);
  text-align: center; font-size: 18px; font-weight: 900;
}
.qty-err { display: block; margin-top: 4px; font-size: 11px; font-weight: 700; color: var(--error); text-align: center; }

/* 白い角丸カード */
.card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  background: var(--surface); border-radius: 20px; box-shadow: 0 2px 0 var(--line-soft);
}

/* 0件・空のとき */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 28px 20px;
  background: var(--surface); border-radius: 24px; text-align: center;
}
.empty-icon {
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 99px; background: var(--surface-3); color: var(--faint); font-size: 26px; font-weight: 900;
}
.empty h2 { margin: 0; font-size: 20px; font-weight: 900; }
.empty p { margin: 0; font-size: 14px; color: var(--sub-2); text-wrap: pretty; }
.empty .note { font-size: 12px; color: var(--sub); }
.empty .btn-primary { width: 100%; }

/* 完了の知らせ */
.toast {
  position: fixed; left: 16px; right: 16px; top: 16px; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  max-width: 420px; margin: 0 auto; padding: 14px 16px;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-pop);
  font-weight: 900; transition: opacity .2s, transform .2s;
}
.toast[hidden] { display: flex; opacity: 0; transform: translateY(-12px); pointer-events: none; }
.toast i {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 99px;
  background: var(--primary); color: var(--green-text); font-style: normal;
}

/* メニュー:スマホでは右上の三本線ボタンで開く(どの画面も同じ形・同じ場所) */
.menu-toggle {
  position: fixed; top: 12px; right: 12px; z-index: 11;
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  width: 48px; height: 48px; padding: 0 13px;
  background: var(--surface); border: 1.5px solid var(--line-soft); border-radius: 16px;
  cursor: pointer;
}
.menu-toggle span { height: 2.5px; border-radius: 2px; background: var(--text); transition: transform .2s, opacity .2s; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }
nav.tabs {
  position: fixed; top: 68px; right: 12px; z-index: 10;
  display: none; flex-direction: column; gap: 2px;
  width: 220px; padding: 6px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop);
  font-size: 0; /* リンク間の「|」を見せない */
}
nav.tabs.open { display: flex; }
nav.tabs a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  font-size: 15px; color: var(--sub-2); text-decoration: none; white-space: nowrap;
}
nav.tabs a::before { content: ""; width: 16px; height: 16px; border: 2px solid var(--faint); border-radius: 5px; }
nav.tabs a[aria-current="page"] { background: var(--green-bg); color: var(--green-text); font-weight: 700; }
nav.tabs a[aria-current="page"]::before { background: var(--green-icon); border-color: var(--green-icon); }

/* PC:メニューは上に並べる */
@media (min-width: 768px) {
  body { padding: 72px 40px 40px; }
  h1 { font-size: 28px; }
  .crumb { font-size: 14px; }
  .btn-outline { flex-direction: row; gap: 6px; padding: 10px 18px; border-radius: 99px; font-size: 14px; }
  .btn-outline small { font-size: 14px; }
  .search { height: 46px; border-radius: 14px; }
  .search input { font-size: 15px; }
  .search .clear { width: 34px; height: 34px; border-radius: 10px; font-size: 15px; }
  .chips { display: flex; gap: 6px; }
  .chip { gap: 7px; height: 42px; padding: 0 16px; font-size: 14px; }
  .dot { width: 9px; height: 9px; }
  .menu-btn { width: auto; gap: 10px; font-size: 14px; white-space: nowrap; }
  .seg { width: 150px; }
  .seg button { font-size: 14px; }
  .card { gap: 12px; padding: 18px; border-radius: 22px; }
  .qty { height: 44px; font-size: 19px; }
  .qty-input { height: 44px; font-size: 19px; }
  .empty { gap: 16px; padding: 56px 24px; }
  .empty-icon { width: 72px; height: 72px; font-size: 30px; }
  .empty h2 { font-size: 22px; }
  .empty p { font-size: 15px; }
  .empty .note { font-size: 13px; }
  .empty .btn-primary { width: auto; height: 48px; }

  .page > h1 { margin: 0 0 16px; }
  .crumb { margin-left: 0; margin-right: 0; }

  .menu-toggle { display: none; }
  nav.tabs {
    top: 0; left: 0; right: 0;
    display: flex; flex-direction: row; gap: 8px;
    width: auto; padding: 12px 32px;
    border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--line-soft);
  }
  nav.tabs a { gap: 10px; padding: 9px 16px; }
}

/* ───────── 一覧 ───────── */

.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 4px 12px; }
.list-head .title { display: flex; align-items: baseline; gap: 16px; }
.export .long { display: none; }

/* 件数:「全◯件中 ◯件」 */
.count { font-size: 14px; }
.count b { font-size: 20px; font-weight: 900; }
.count .all { color: var(--sub); }
.list-head .count { display: none; }

/* 探す・絞り込む・並べ替える・見せ方 */
.tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "search search"
    "chips  chips"
    "cat    sort"
    "count  view";
  gap: 12px 8px;
  align-items: center;
  margin-bottom: 12px;
}
.tools .search { grid-area: search; }
.tools .chips { grid-area: chips; }
.tools #catMenu { grid-area: cat; }
.tools #sortMenu { grid-area: sort; }
.tools .count { grid-area: count; padding: 0 4px; }
.tools .seg { grid-area: view; justify-self: end; }

.hint { margin: 0 4px 10px; font-size: 11px; color: var(--sub); }
.hint .pc { display: none; }

/* カード */
.cards { display: flex; flex-direction: column; gap: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-head > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card .name { font-size: 17px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--sub); }
.sites { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.site { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.site-label { font-size: 11px; color: var(--sub); }
.site .sum {
  width: 100%; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border-radius: 12px; font-size: 18px; font-weight: 900;
}

/* 表(スマホでは横にスクロール) */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: 20px; }
.table-wrap table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.table-wrap th, .table-wrap td { padding: 8px 12px; text-align: left; }
.table-wrap th { background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--sub-2); }
.table-wrap td { height: 58px; border-top: 1px solid var(--line-row); font-size: 14px; }
.table-wrap th:first-child, .table-wrap td:first-child { position: sticky; left: 0; z-index: 1; }
.table-wrap th:first-child { background: var(--surface-2); }
.table-wrap td:first-child { background: var(--surface); box-shadow: 1px 0 0 var(--line-row); }
.table-wrap .name { font-size: 15px; font-weight: 700; }
.table-wrap .c { text-align: center; }
.table-wrap .r { text-align: right; }
.table-wrap td.cat { color: var(--sub-2); }
.table-wrap td.sum { font-size: 17px; font-weight: 900; }
.table-wrap td.date { color: var(--sub-2); }
.table-wrap .qty { width: 64px; height: 38px; margin: 0 auto; border-radius: 10px; font-size: 16px; font-weight: 700; }
.table-wrap .qty-input { width: 72px; height: 38px; border-radius: 10px; font-size: 16px; }
.table-wrap .badge { padding: 4px 12px; }

@media (min-width: 768px) {
  .list-head { margin: 0 0 18px; }
  .list-head .count { display: inline; font-size: 15px; }
  .list-head .count b { font-size: 22px; }
  .export .short { display: none; }
  .export .long { display: inline; }

  .tools {
    grid-template-columns: 320px auto auto 1fr auto auto;
    grid-template-areas: "search chips cat . sort view";
    gap: 12px;
    margin-bottom: 18px;
  }
  .tools .count { display: none; }
  #sortMenu .menu-list { left: auto; right: 0; }

  .hint { margin: 0 0 14px; font-size: 13px; }
  .hint .sp { display: none; }
  .hint .pc { display: inline; }

  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
  .card .name { font-size: 18px; }
  .meta { gap: 8px; }
  .sites { gap: 8px; }
  .site-label { font-size: 12px; }
  .site .sum { height: 44px; font-size: 19px; }

  .table-wrap th, .table-wrap td { padding: 8px 16px; }
  .table-wrap th { padding-top: 14px; padding-bottom: 14px; font-size: 13px; }
  .table-wrap th:first-child, .table-wrap td:first-child { padding-left: 24px; }
  .table-wrap th:last-child, .table-wrap td:last-child { padding-right: 24px; }
}
