/* 倉庫の在庫（デモ）。色と線は ky-nippo（sasara.）と同じ値 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --ink: #1a1d21;
  --sub: #5b636d;
  --line: #c9ced6;
  --line-strong: #7b838e;
  --bg: #eef1f5;
  --paper: #fff;
  --accent: #0b57a4;
  --accent-soft: #e8f0fa;
  --warn: #c62828;
  --warn-soft: #fdecea;
  --ok: #1b7a3d;
  --ok-soft: #e7f4ec;
  --mark: #e8622a;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); }

.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--accent); color: #fff;
}
.appbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.appbar h1 small { font-size: 12px; font-weight: 400; opacity: .85; margin-left: 8px; }
.appbar .spacer { flex: 1; }
.appbar a { color: #fff; text-decoration: none; font-size: 14px; }
.appbar .live { font-size: 12px; opacity: .9; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; margin-bottom: 14px; }
.panel h2 { font-size: 16px; margin: 0 0 10px; }
.note { font-size: 13px; color: var(--sub); }

button, .btn {
  font: inherit; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink);
  border-radius: 4px; padding: 8px 14px; min-height: 40px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.warn { background: var(--paper); border-color: var(--warn); color: var(--warn); }
button:disabled { opacity: .45; cursor: default; }

input[type="text"], input[type="search"], input[type="number"], input[type="password"], select {
  font: inherit; border: 1px solid var(--line-strong); border-radius: 4px; padding: 7px 10px; background: #fff; min-height: 40px;
}

table { width: 100%; border-collapse: collapse; background: var(--paper); }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; font-size: 14px; }
th { background: #f5f7fa; font-weight: 700; white-space: nowrap; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
tr.fresh td { animation: fresh 3s ease-out; }
@keyframes fresh { from { background: #fff3c4; } to { background: transparent; } }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--sub); white-space: nowrap; }
.tag.warn { border-color: var(--warn); color: var(--warn); }
.tag.ok { border-color: var(--ok); color: var(--ok); }
.tag.accent { border-color: var(--accent); color: var(--accent); }

.msg { padding: 10px 14px; border-radius: 4px; margin-bottom: 12px; font-size: 14px; }
.msg.err { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0b4ae; }
.msg.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #a9d8b9; }
.msg.warn { background: #fff6d8; color: #6b5300; border: 1px solid #e6cf7a; }

/* ---------- 入口 ---------- */
.home-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 18px 0; }
.home-tile {
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 190px; padding: 18px 20px; border-radius: 4px;
  color: #fff; text-decoration: none;
}
.home-tile b { font-size: 26px; display: block; }
.home-tile span { font-size: 14px; opacity: .92; }
.home-tile.t1 { background: #0b57a4; }
.home-tile.t2 { background: #1b7a3d; }
.home-tile.t3 { background: #c76a12; }
.home-tile.t4 { background: #5b4a8a; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } .home-tile { min-height: 120px; } }

/* ---------- 管理画面 ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 2px solid var(--accent); }
.tabs button { border: 1px solid var(--line); border-bottom: none; border-radius: 4px 4px 0 0; background: #f5f7fa; min-height: 40px; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs button .count { margin-left: 6px; font-size: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 8px 14px; min-width: 140px; }
.stat b { font-size: 22px; display: block; }
.stat span { font-size: 12px; color: var(--sub); }
.detail { border-left: 3px solid var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.low td:first-child { border-left: 3px solid var(--warn); }

/* ---------- 持出台 ---------- */
body.station { background: var(--bg); }
.st-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 14px; padding: 14px; min-height: calc(100vh - 52px); }
@media (max-width: 900px) { .st-wrap { grid-template-columns: 1fr; } }
.st-main { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 20px 24px; display: flex; flex-direction: column; }
.st-side { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; overflow: auto; max-height: calc(100vh - 80px); }
.st-side h2 { font-size: 15px; margin: 0 0 8px; }
.st-who { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.st-who b { font-size: 26px; }
.st-mode { font-size: 14px; padding: 2px 10px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.st-mode.return { background: var(--ok-soft); color: var(--ok); }
.st-mode.count { background: #fff1e6; color: #b45309; }
.st-mode.short { background: var(--warn-soft); color: var(--warn); }
.st-prompt { font-size: 30px; font-weight: 700; margin: 18px 0 8px; }
.st-sub { font-size: 16px; color: var(--sub); }
.st-card { border: 2px solid var(--accent); border-radius: 4px; padding: 14px 18px; margin: 14px 0; }
.st-card .name { font-size: 26px; font-weight: 700; }
.st-card .where { font-size: 18px; margin-top: 4px; }
.st-card .where b { font-size: 26px; color: var(--accent); }
.st-big-shelf { font-size: 64px; font-weight: 700; color: var(--ok); line-height: 1.1; }
.st-qty { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.st-qty .num { font-size: 48px; font-weight: 700; min-width: 120px; text-align: center; }
.st-qty button { min-width: 64px; min-height: 64px; font-size: 26px; }
.st-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.st-row label { font-size: 15px; color: var(--sub); }
.st-row select { font-size: 18px; min-height: 48px; }
.st-actions { margin-top: auto; padding-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.st-actions button { min-height: 56px; font-size: 17px; padding: 8px 18px; }
.st-actions button.ok { background: var(--accent); color: #fff; border-color: var(--accent); min-width: 160px; }
.st-flash { padding: 12px 16px; border-radius: 4px; font-size: 18px; margin: 8px 0; }
.st-flash.ok { background: var(--ok-soft); color: var(--ok); }
.st-flash.err { background: var(--warn-soft); color: var(--warn); }
.st-flash.ask { background: #fff6d8; color: #6b5300; border: 1px solid #e6cf7a; }
.st-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-top: 10px; }
.st-people button { min-height: 60px; font-size: 18px; }
.st-list { list-style: none; margin: 0; padding: 0; }
.st-list li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.st-list li small { color: var(--sub); display: block; }
.st-count th, .st-count td { font-size: 16px; }
.st-count tr.focus td { background: #fff6d8; }
.st-manual { display: flex; gap: 6px; margin-top: 12px; }
.st-manual input { flex: 1; }
.st-hint { font-size: 13px; color: var(--sub); margin-top: 8px; }

/* ---------- ラベル ---------- */
body.labels { background: #fff; }
.label-sec { margin: 0 0 18px; }
.label-sec h2 { font-size: 15px; margin: 12px 0 8px; break-after: avoid; page-break-after: avoid; }
.label-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
.label { border: 1px dashed #9aa1aa; padding: 3mm 4mm; break-inside: avoid; text-align: center; }
.label .t { font-size: 13px; font-weight: 700; line-height: 1.3; min-height: 1.3em; }
.label .big { font-size: 34px; font-weight: 700; line-height: 1.1; }
.label .c { font-size: 11px; letter-spacing: .08em; color: #333; }
/* 画面では画素にそろえた大きさのまま出す（縮めるとにじんで画面から読みにくい）。印刷では mm で */
.label svg { display: block; margin: 2mm auto 1mm; }
.label.card { text-align: left; }
.label.card .org { font-size: 10px; color: #555; }
.label.card .nm { font-size: 20px; font-weight: 700; }
@media print {
  html, body { background: #fff !important; }
  .label svg { width: 48mm; height: 13mm; }
  .no-print { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  @page { size: A4 portrait; margin: 10mm; }
}

/* ---------- 使い方（A4 1 枚） ---------- */
.guide-page { max-width: 900px; margin: 0 auto; padding: 20px 16px 28px; background: var(--paper); }
.guide-title { font-size: 24px; margin: 0 0 6px; }
.guide-lead { font-size: 14px; margin: 0 0 12px; color: var(--sub); }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.guide-grid section { border-top: 2px solid var(--ink); padding-top: 6px; }
.guide-grid h2 { font-size: 15px; margin: 0 0 4px; }
.guide-grid ol, .guide-grid ul { margin: 0; padding-left: 1.3em; font-size: 13px; line-height: 1.55; }
.guide-note { font-size: 12px; color: var(--sub); margin: 4px 0 0; }
.guide-foot { font-size: 12px; color: var(--sub); margin: 14px 0 0; border-top: 1px solid var(--line); padding-top: 6px; }
@media (max-width: 700px) { .guide-grid { grid-template-columns: 1fr; } }
@media print {
  body.guide { background: #fff; }
  .guide-page { max-width: none; padding: 0; }
  .guide-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- 管理画面の一覧表 ---------- */
.list-when { font-size: 13px; color: var(--sub); margin-bottom: 8px; }
.list-summary .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.list-summary .card { border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; }
.list-summary .card b { display: block; font-size: 24px; }
.list-summary .card span { font-size: 12px; color: var(--sub); }
.list-summary .card.warn { border-color: var(--warn); }
.list-summary .card.warn b { color: var(--warn); }
.table-scroll { overflow-x: auto; }
.list-table { min-width: 860px; }
.list-table td { vertical-align: top; }
.list-outs { font-size: 13px; }
.list-outs div + div { margin-top: 2px; }
@page wide { size: A4 landscape; margin: 8mm; }
@media print {
  body.print-list .wrap { padding: 0; }
  body.print-list .list-summary, body.print-list .list-table { page: wide; }
  body.print-list .list-summary { border: 0; padding: 0; margin-bottom: 6px; }
  body.print-list .list-table { font-size: 10px; width: 100%; min-width: 0; }
  body.print-list .table-scroll { overflow: visible; }
  body.print-list .list-table th, body.print-list .list-table td { padding: 3px 4px; }
  body.print-list .list-table tr { break-inside: avoid; }
  body.print-list .list-table thead { display: table-header-group; }
}

/* ---------- 管理画面の登録 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 12px; margin: 8px 0; }
.form-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--sub); }
.form-grid label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; }
.form-grid input, .form-grid select { font-size: 15px; }
.edit-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.edit-box summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.toolbar .spacer { flex: 1; }

/* ---------- 3D の倉庫図 ---------- */
.map-wrap { display: grid; grid-template-columns: 1fr 360px; gap: 12px; padding: 12px; height: calc(100vh - 52px); }
.map-stage { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; min-height: 320px; }
.map-scene { position: absolute; inset: 0; }
.map-scene canvas { display: block; }
.map-buttons { position: absolute; left: 10px; top: 10px; max-width: calc(100% - 20px); display: flex; gap: 6px; flex-wrap: wrap; }
.map-buttons button { min-height: 40px; background: rgba(255,255,255,.92); }
.map-buttons .map-cut { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.map-buttons .map-cut[hidden] { display: none; }
.map-cut span { font-size: 13px; color: var(--sub); background: rgba(255,255,255,.88); border-radius: 4px; padding: 4px 8px; }
.map-cut button[aria-pressed="true"], .map-buttons > button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.map-hint { position: absolute; left: 10px; bottom: 10px; right: 10px; font-size: 13px; color: var(--sub); background: rgba(255,255,255,.88); border-radius: 4px; padding: 6px 10px; pointer-events: none; }
/* 中身の名前の札（図の上に重ねる）と、物までの線 */
.map-tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.map-tags svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-tags line { stroke: var(--line-strong); stroke-width: 1; }
.map-tags circle { fill: var(--mark); }
.map-tag { position: absolute; left: 0; top: 0; pointer-events: auto; min-height: 0; max-width: 240px; padding: 3px 8px; font-size: 12px; line-height: 1.35; text-align: left;
  background: rgba(255,255,255,.96); border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
div.map-tag { cursor: default; }
.map-tag small { color: var(--sub); margin-left: 6px; }
.map-tag.unsure { border-style: dashed; }
.map-tag.on { border: 2px solid var(--mark); font-weight: 700; }
/* 図の上の中身の一覧。広い画面では右の欄に同じものが出るので出さない */
.map-card { position: absolute; left: 8px; right: 8px; bottom: 8px; max-height: 44%; overflow: auto; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 4px; padding: 8px 12px 4px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.map-card[hidden] { display: none; }
.map-card-head { display: flex; align-items: center; gap: 6px; position: sticky; top: -8px; background: var(--paper); padding: 2px 0 6px; }
.map-card-head b { flex: 1; font-size: 18px; color: var(--mark); }
.map-card-head button { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.map-card-sub { font-size: 13px; color: var(--sub); margin-top: 4px; }
.map-card-empty { font-size: 13px; color: var(--sub); margin: 6px 0; }
.map-card .st-list li { padding: 5px 0; }
@media (min-width: 901px) {
  .map-card { display: none !important; }
}
/* 置き場所を決めているときの帯（ボタンの下に 1 行で） */
.map-mode { flex-basis: 100%; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: #fff7f2; border: 1px solid var(--mark); border-radius: 4px; padding: 6px 10px; font-size: 13px; }
.map-mode[hidden] { display: none; }
.map-mode b { color: var(--mark); }
.map-mode .msg-line { flex-basis: 100%; color: var(--ink); }
.map-mode .msg-line.err { color: var(--warn); }
.map-mode .msg-line.ok { color: var(--ok); }
.map-mode .spacer { flex: 1; }
.map-arrange { background: var(--accent-soft); border-color: var(--accent); }
.map-arrange b { color: var(--accent); }
.map-buttons .map-mode button:disabled { opacity: .45; }
.arrange-help { display: none; }
.arrange-help p { margin: 0 0 8px; font-size: 14px; }
body.arranging .map-side > :not(.arrange-help) { display: none; }
body.arranging .arrange-help { display: block; }
body.arranging .map-cut { display: none; }
body.arranging .map-hint { display: none; }
.map-buttons .map-mode button { min-height: 32px; padding: 3px 10px; font-size: 13px; background: #fff; }
.map-place-row { display: flex; gap: 8px; }
/* 図から持ち出す・戻す・数を直す欄 */
.map-act { border-top: 1px solid var(--line); margin: 6px 0 4px; padding-top: 6px; }
.panel .map-act { border-top: 0; margin: 0; padding-top: 0; }
.act-line { display: flex; align-items: center; gap: 6px; margin: 6px 0; flex-wrap: wrap; font-size: 14px; }
.act-line select { flex: 1; min-width: 0; }
.act-qty { width: 90px; text-align: right; font-size: 18px; }
.act-line button { min-height: 38px; }
.act-buttons button { flex: 1; }
.act-units { list-style: none; margin: 4px 0; padding: 0; }
.act-units li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.act-units button { min-height: 34px; padding: 4px 12px; flex-shrink: 0; white-space: nowrap; }
.act-line button { white-space: nowrap; }
.act-ask .msg { margin: 6px 0 0; }
.map-place-row select { flex: 1; }
.map-side { overflow: auto; }
.map-side .panel { margin-bottom: 10px; }
.map-side h2 { font-size: 15px; }
.map-place { font-size: 34px; font-weight: 700; color: var(--mark); line-height: 1.2; }
@media (max-width: 900px) {
  .map-wrap { grid-template-columns: 1fr; height: auto; }
  .map-stage { height: 58vh; }
  .map-stage.has-card { height: 72vh; }
  .map-stage.has-act { height: 80vh; }
  .map-stage.has-act .map-card { max-height: 60%; }
  .map-stage.has-card .map-hint { display: none; }
  /* 配置を直しているときは、直す帯の分だけ図を高くする */
  body.arranging .map-stage { height: 72vh; }
}
@media (max-width: 600px) {
  .map-buttons { gap: 4px; }
  .map-buttons button { min-height: 34px; padding: 4px 9px; font-size: 13px; }
  /* 狭い画面で配置を直しているときは、見る向きのボタンを「上から」と「配置を直す」だけにして図を広く見せる */
  body.arranging .map-buttons > button:not([data-view="top"]):not([data-view="arrange"]) { display: none; }
}

/* ---------- 運用の形（記録・表の取り込み・入荷と数の直し） ---------- */
a.button, label.button { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--paper); color: var(--ink); font-size: 15px; text-decoration: none; cursor: pointer; }
a.button:hover, label.button:hover { border-color: var(--accent); color: var(--accent); }
.stock-forms { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.stock-forms .toolbar { margin-bottom: 6px; }
.stock-forms .sf-label { min-width: 9em; font-size: 14px; }
.imp-result { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.imp-result h3 { font-size: 14px; margin: 12px 0 6px; }
.print-only { display: none; }
@media print {
  .print-only { display: block; }
}
