:root {
  --bg: #f5f6f8; --card: #fff; --text: #1f2430; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2f6f5e; --accent-weak: #e6f2ee; --danger: #b42318; --danger-weak: #fdecea;
  --hq: #3b4a6b; --warn-weak: #fff6e0;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
main { max-width: 1080px; margin: 0 auto; padding: 16px 16px 96px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 16px;
  background: var(--accent); color: #fff; }
.role-hq .top { background: var(--hq); }
.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.05rem; }
.tag { margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: rgba(255,255,255,.2); font-size: .75rem; }
.top nav { display: flex; gap: 4px 16px; flex-wrap: wrap; }
.top nav a { opacity: .9; } .top nav a:hover { opacity: 1; text-decoration: underline; }
.me { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.linkish { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; padding: 2px 10px; border-radius: 6px; cursor: pointer; font: inherit; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 420px; margin: 40px auto; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .pre { white-space: pre-wrap; }
.inline { display: inline; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; background: var(--accent-weak); border: 1px solid #b9dccf; }
.flash.error { background: var(--danger-weak); border-color: #f4b8b0; color: var(--danger); }

label { display: block; font-size: .9rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); padding: 8px 10px;
  border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; vertical-align: middle; }
label.check { color: var(--text); display: flex; align-items: center; }
textarea { resize: vertical; }
button { font: inherit; padding: 8px 16px; border-radius: 8px; border: 1px solid #cfd4dc; background: #fff; cursor: pointer; white-space: nowrap; }
button:hover { background: #f0f2f5; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.role-hq button.primary { background: var(--hq); border-color: var(--hq); }
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.danger { color: var(--danger); border-color: #f0b4ad; }
button.danger:hover { background: var(--danger-weak); }

.stack { display: grid; gap: 12px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.grid-form .full { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { flex: 1 1 200px; }
details > summary { cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .85rem; background: #fafbfc; white-space: nowrap; }
td input, td select { min-width: 140px; }
.table-wrap > p { padding: 0 12px 10px; margin: 8px 0 0; }
.num { text-align: right; white-space: nowrap; }
tfoot th { background: none; color: var(--text); font-size: 1rem; }
tr.off td { color: var(--muted); background: #fafafa; }
tr.attn td { background: var(--warn-weak); }

.badge { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .8rem; white-space: nowrap; border: 1px solid transparent; }
.badge.big { font-size: .95rem; padding: 3px 14px; }
.s-new { background: #fff1d6; color: #8a5a00; border-color: #f4d48c; }
.s-arranging { background: #e3edff; color: #1d4ed8; border-color: #b9cdf7; }
.s-shipped { background: var(--accent-weak); color: var(--accent); border-color: #b9dccf; }
.s-cancelled { background: #f0f0f0; color: #6b7280; border-color: #ddd; }
.head-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head-row h1 { margin-bottom: .6rem; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--text); }
.tile span { display: block; color: var(--muted); font-size: .85rem; }
.tile strong { font-size: 1.6rem; }
.tile.on { border-color: var(--hq); box-shadow: inset 0 0 0 1px var(--hq); }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.meta dt { color: var(--muted); } dl.meta dd { margin: 0; }
ul.events { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
ul.events li { padding: 4px 0; border-bottom: 1px dashed var(--line); }

ul.catalog { list-style: none; margin: 0; padding: 0; }
ul.catalog li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); border-radius: 6px; }
ul.catalog li:last-child { border-bottom: 0; }
ul.catalog li.picked { background: var(--accent-weak); }
.pname { display: flex; flex-direction: column; min-width: 0; }
.pname .muted { font-size: .85rem; }
.qty { display: flex; align-items: center; gap: 6px; color: var(--text); flex: none; }
.qty { gap: 4px; }
.qty input { width: 64px; height: 44px; text-align: center; margin: 0; font-size: 1.1rem; padding: 6px 4px; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty .step { width: 44px; height: 44px; padding: 0; font-size: 1.3rem; line-height: 1; touch-action: manipulation; }
.qty .unit { min-width: 2em; font-size: .9rem; color: var(--muted); }
.submitbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.submitbar strong { font-size: 1.15rem; }
.submitbar button { padding: 10px 22px; }

/* 一覧（発注履歴・申請）：行全体をタップできるリスト */
ul.rowlist { list-style: none; padding: 0; margin: 0 0 16px; overflow: hidden; }
ul.rowlist li + li { border-top: 1px solid var(--line); }
ul.rowlist a, .rl-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); text-decoration: none; }
ul.rowlist a:hover { background: #fafbfc; }
.rl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rl-sub { white-space: nowrap; }
.thumb.sm { width: 44px; height: 44px; }

@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .me { margin-left: 0; width: 100%; justify-content: space-between; }
  th, td { padding: 8px; }
  main { padding: 12px 12px 104px; }
  .card { padding: 12px; }
  ul.catalog li { display: grid; grid-template-columns: 48px 1fr; gap: 6px 12px; padding: 10px 4px; }
  ul.catalog li .thumb { width: 48px; height: 48px; grid-row: span 2; align-self: start; }
  ul.catalog .qty { justify-self: end; }
  ul.rowlist a { flex-wrap: wrap; gap: 4px 12px; }
  ul.rowlist a .rl-main { flex-basis: 100%; flex-direction: row; justify-content: space-between; align-items: baseline; gap: 8px; }
  ul.rowlist a .rl-sub { flex: 1; }
}

/* 手配リスト */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs a { padding: 6px 14px; border: 1px solid var(--line); border-radius: 99px; background: #fff; text-decoration: none; color: var(--text); font-size: .9rem; }
.tabs a.on { background: var(--hq); border-color: var(--hq); color: #fff; }
.noscreen { display: none; }
@media print {
  .top, .noprint, .flash { display: none !important; }
  .noscreen { display: table-cell; }
  body { background: #fff; font-size: 12px; }
  main { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; margin-bottom: 12px; }
  table.picklist th, table.picklist td { padding: 4px 6px; border-bottom: 1px solid #999; }
  a { color: inherit; text-decoration: none; }
}

/* 画像・申請・通知 */
.thumb { flex: none; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: #eef0f3; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.none { background: repeating-linear-gradient(45deg, #f1f3f5, #f1f3f5 6px, #e9ecef 6px, #e9ecef 12px); }
ul.catalog li .pname { flex: 1; }
img.mini { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.thumbcell { width: 56px; }
img.preview { max-width: 200px; max-height: 200px; border-radius: 8px; border: 1px solid var(--line); }
.image-field { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.image-field > div { flex: 1 1 260px; display: grid; gap: 8px; }
.count { display: inline-block; min-width: 1.4em; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: #e8590c; color: #fff; font-size: .75rem; text-align: center; }
.err { color: var(--danger); }
.r-pending { background: #fff1d6; color: #8a5a00; border-color: #f4d48c; }
.r-adopted { background: var(--accent-weak); color: var(--accent); border-color: #b9dccf; }
.r-declined { background: #f0f0f0; color: #6b7280; border-color: #ddd; }
.req-photo { max-width: 100%; max-height: 320px; border-radius: 8px; border: 1px solid var(--line); }
.status-line { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.status-line .dot { width: 12px; height: 12px; border-radius: 50%; background: #adb5bd; }
.status-line .dot.on { background: #2f9e44; }
ol.steps li { margin-bottom: 6px; }
code { background: #f1f3f5; padding: 1px 6px; border-radius: 4px; font-size: .9em; }
