/* 画面デザイン案(在庫管理表の画面デザイン.html)の見た目。色・大きさ・形はデザイン案に合わせている */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1b2733;
  --muted: #4a5866;
  --line: #cbd3db;
  --line-soft: #dde3e9;
  --field-line: #7a8794;
  --head-bg: #eef2f6;
  --accent: #1f4e79;
  --accent-dark: #123556;
  --accent-soft: #e4edf5;
  --accent-soft-line: #9db6cf;
  --danger: #a31515;
  --low-bg: #fde8e8;
  --low-row: #fdeeee;
  --minus: #7a0e0e;
  --minus-row: #f9dcdc;
  --out-bg: #fff1dc;
  --out-text: #6b4200;
  --out-line: #d9a95b;
  --off-bg: #e9ecef;
  --off-text: #3a4651;
  --off-line: #9aa5b0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* ---------- 上の帯とタブ ---------- */
header.top {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 max(32px, calc((100% - 1280px) / 2 + 32px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 16px;
}
header.top h1 { font-size: 22px; font-weight: 700; margin: 0; padding: 18px 0 8px; white-space: nowrap; }
.who { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; padding-top: 10px; }
.who .name { font-size: 15px; }
nav.tabs { display: flex; flex-wrap: wrap; gap: 4px; flex: 0 0 100%; order: 3; }
nav.tabs button {
  font: inherit;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-bottom: 4px solid transparent;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}
nav.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 700; }
nav.tabs button:hover { background: var(--head-bg); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

main { padding: 28px 32px 48px; max-width: 1280px; margin: 0 auto; }
main > section[hidden] { display: none; }
h2 { margin: 0 0 20px; font-size: 26px; font-weight: 700; }
h3 { margin: 36px 0 14px; font-size: 20px; font-weight: 700; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  max-width: 880px;
  margin: 0 0 20px;
}

/* ---------- 絞り込み・入力欄 ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; margin-bottom: 20px; }
.controls label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 700; }
.controls label.chk { flex-direction: row; align-items: center; gap: 10px; min-height: 48px; font-size: 16px; font-weight: 400; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

input[type="text"], input[type="search"], input[type="date"], input[type="password"], select, textarea {
  font: inherit;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--field-line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  max-width: 100%;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
input.bad, select.bad, textarea.bad { border: 2px solid var(--danger); padding: 0 11px; }
textarea.bad { padding: 9px 11px; }
fieldset.bad .seg { border: 2px solid var(--danger); }

.err { color: var(--danger); font-weight: 700; font-size: 14px; }
.err:not(:empty) { display: flex; align-items: center; gap: 6px; }
.err:not(:empty)::before {
  content: "!";
  flex: none;
  width: 16px; height: 16px;
  border: 1.6px solid var(--danger);
  border-radius: 50%;
  font-size: 11px;
  line-height: 13px;
  text-align: center;
}

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  min-height: 52px;
  min-width: 180px;
  padding: 0 28px;
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn.sub { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn.sub:hover { background: var(--accent-soft); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn.dangerfill { background: var(--danger); color: #fff; }
.btn.small { min-height: 44px; min-width: 64px; padding: 0 12px; font-size: 15px; }
.btn:disabled { border: 1px solid #b8c1ca; color: #5b6773; background: var(--head-bg); cursor: default; }
header.top .btn.small { min-height: 40px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 20px 28px; }
.form-grid .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.form-grid .field.wide { grid-column: 1 / -1; }
.field > label, .field > legend { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 0; }
.field > legend { margin-bottom: 6px; float: left; width: 100%; }
.field > legend + * { clear: both; }
.field input[type="text"], .field input[type="date"], .field select, .field textarea { width: 100%; }
.field .req { padding: 1px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; margin: 0; }
.field .req:empty { display: none; }
.field .hint { color: var(--muted); font-size: 14px; }
.btns { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 24px; }
dialog .btns { justify-content: flex-end; }

.seg {
  display: flex; flex-wrap: wrap; gap: 4px 28px; align-items: center;
  min-height: 48px; padding: 0 12px;
  border: 1px solid var(--field-line); border-radius: 6px; background: #fff;
}
.seg label { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; font-weight: 400; cursor: pointer; }

/* ---------- 表 ---------- */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { padding: 12px 10px; border-top: 1px solid var(--line-soft); text-align: left; vertical-align: middle; font-size: 15px; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
thead th { background: var(--head-bg); border-top: 0; font-size: 14px; padding-top: 0; padding-bottom: 0; white-space: nowrap; }
thead th:not(:has(button)) { padding-top: 14px; padding-bottom: 14px; }
th .sb {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-weight: 700; color: var(--text);
  background: none; border: 0; padding: 0; min-height: 52px; cursor: pointer; white-space: nowrap;
}
th .sb span { color: var(--muted); }
td.num, th.num { text-align: right; white-space: nowrap; }
#st-table td { padding-top: 16px; padding-bottom: 16px; font-size: 16px; }
#st-table td.num { font-weight: 700; font-size: 20px; }
tr.click { cursor: pointer; }
tr.click:hover td { filter: brightness(0.97); }
tr.click .lk { color: var(--accent); font-weight: 700; font-size: 17px; text-decoration: underline; }
tr.row-low td { background: var(--low-row); }
tr.row-low td.num { color: var(--danger); }
tr.row-minus td { background: var(--minus-row); }
tr.row-minus td.num { color: var(--minus); }
tr.unused td { color: #5b6773; }
tr.deleted td { color: #5b6773; text-decoration: line-through; }
tr.deleted td.keep { text-decoration: none; }
#hi-table td { font-size: 15px; }
#it-list td { padding-top: 14px; padding-bottom: 14px; font-weight: 700; }
#it-list td.num { font-weight: 400; }
#it-list td:not(:first-child) { font-weight: 400; }

/* 状態・入荷出荷・印のバッジ */
.bd, .badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.bd.ok { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft-line); }
.bd.lo { background: var(--low-bg); color: var(--danger); border-color: var(--danger); }
.bd.ng { background: var(--minus); color: #fff; border-color: var(--minus); }
.bd.inb { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft-line); font-size: 13px; padding: 3px 8px; }
.bd.outb { background: var(--out-bg); color: var(--out-text); border-color: var(--out-line); font-size: 13px; padding: 3px 8px; }
.bd.off { background: var(--off-bg); color: var(--off-text); border-color: var(--off-line); }
.badge { background: #fff; color: var(--off-text); border-color: var(--field-line); font: inherit; font-size: 13px; font-weight: 700; padding: 3px 8px; margin: 2px 4px 2px 0; }
.badge.short { background: var(--low-bg); color: var(--danger); border-color: var(--danger); }
button.badge { cursor: pointer; }

.note { color: var(--muted); font-size: 15px; margin: 12px 0 0; }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin-top: 24px; }
.pager .btn { min-height: 48px; min-width: 120px; font-size: 16px; }
.empty { padding: 20px; color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 6px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#toast.show { opacity: 1; }

/* ---------- 小さな窓 ---------- */
dialog {
  border: 0;
  border-radius: 10px;
  padding: 28px;
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(20, 30, 40, 0.55); }
dialog h3 { font-size: 20px; margin: 0 0 20px; }
dialog .form-grid { gap: 18px 24px; }
dialog .btn { min-width: 0; min-height: 52px; font-size: 16px; padding: 0 24px; }
dialog .btn.sub { color: var(--text); border-color: var(--field-line); }
dialog .btn.sub:hover { background: var(--head-bg); }
dialog .btn.danger { border-width: 2px; }
.msg { white-space: pre-wrap; margin: 0; font-size: 18px; font-weight: 500; line-height: 1.7; }
dialog:has(.msg) { max-width: 440px; }
.diff { margin: 4px 0 12px; padding: 10px 12px; background: var(--bg); border-radius: 6px; }
.diff div { margin: 2px 0; }

/* ---------- スマホ ---------- */
/* 【仮】表は、横にずらして見る形のまま(README 5-8 の44番は未定。案は決まるまで選ばない) */
@media (max-width: 700px) {
  header.top { padding: 0 16px; }
  header.top h1 { font-size: 20px; padding: 14px 0 6px; }
  nav.tabs { flex-wrap: nowrap; }
  nav.tabs button { flex: 1 1 auto; justify-content: center; padding: 0 6px; }
  main { padding: 20px 16px 40px; }
  h2 { font-size: 22px; }
  .card { padding: 20px 16px; }
  .controls { gap: 12px 16px; }
  input[type="search"] { min-width: 0; width: 100%; }
  .controls label { width: 100%; }
  .controls label.chk { width: auto; }
  dialog { padding: 20px 16px; }
}
