/* 中浜倉庫 資材ロケーション管理 — スタイル
   トークン → 基本部品 → ヘッダー/KPI/タブ → マップ → 各タブ → モーダル → レスポンシブ */

:root {
  --bg: #f0ede7;
  --card: #ffffff;
  --line: #e8e3da;
  --line-soft: #f1ece3;
  --ink: #2b2620;
  --ink-2: #6f675c;
  --ink-3: #a29a8c;
  --brand: #b07a3f;
  --brand-dark: #9a692f;
  --header-bg: #33281f;
  --green: #128a5e;
  --red: #c05a24;
  --alert: #c0574a;
  --blue: #4a70c0;
  --amber: #9a6a2f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 26, 18, .04), 0 12px 32px -20px rgba(31, 26, 18, .35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: rgba(31, 26, 18, .08); }
button, a, select, input, textarea, label, .chip, .wm-cell, .wm-temp, .tab-btn, tr[data-jump] { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  font-family: 'Zen Kaku Gothic New', system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }

/* ---------- 基本部品 ---------- */

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 15px 18px; display: flex; flex-direction: column; gap: 13px; }
.ch { padding: 13px 18px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ct { font-size: 14px; font-weight: 700; }
.lbl { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--ink-3); }
.num { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { border: 0; border-radius: 10px; padding: 9px 16px; font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit; transition: background .12s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #f2eee7; color: #3a352e; }
.btn-ghost:hover { background: #e8e2d8; }
.btn-dark { background: #4a3d31; color: #f3ede2; }
.btn-dark:hover { background: #5a4b3c; }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }

.chip { border: 1px solid #ded7cb; background: #faf8f4; border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; transition: background .12s; user-select: none; }
.chip:hover { background: #f1ece1; }
.chip.is-on { background: var(--ink); color: #fbf8f1; border-color: var(--ink); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

.seg { display: flex; background: #efeae1; border: 1px solid #e2dccf; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: #7a7267; cursor: pointer; font-family: inherit; white-space: nowrap; transition: background .12s; }
.seg button.is-on, .seg-sm button.is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(31, 26, 18, .14); }
.seg-sm { padding: 2px; }
.seg-sm button { padding: 4px 10px; font-size: 11.5px; }

.fld { border: 1px solid #ddd6ca; border-radius: 9px; padding: 9px 11px; font-size: 13.5px; font-family: inherit; color: var(--ink); background: #fff; }
.fld:focus { outline: 2px solid #d9c19b; border-color: #c9a86e; }
.flbl { display: block; font-size: 11.5px; font-weight: 600; color: #8a8277; margin-bottom: 6px; }
.flbl-sub { color: #b3aa9c; font-weight: 400; }
.fldw { display: flex; flex-direction: column; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 11px; font-size: 11.5px; font-weight: 700; }
.badge-sm { padding: 2px 9px; font-size: 11px; }
.mini-badge { display: inline-flex; align-items: center; border-radius: 7px; padding: 5px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; color: var(--ink-3); text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: #fff; z-index: 2; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13px; color: #3a352e; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--ink-2); }
.tbl-scroll { max-height: 430px; overflow: auto; }
.tbl-scroll-tall { max-height: 60vh; }
.empty-cell { text-align: center; color: #b0a897; padding: 24px !important; }
.td-loc { font-weight: 600; }
.td-reason { display: block; font-size: 10px; color: var(--ink-3); }
.td-note { display: block; font-size: 11px; color: #a08d5f; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.io-in { color: var(--green); font-weight: 700; }
.io-out { color: var(--red); font-weight: 700; }
.io-adj { color: var(--blue); font-weight: 700; }
.io-move { color: var(--amber); font-weight: 700; }

.linklike { border: 0; background: #efe6d6; border-radius: 6px; padding: 4px 10px; font-size: 12px; color: #8a7250; cursor: pointer; font-family: inherit; }
.linklike:hover { background: #e8dcc6; }

/* ---------- ヘッダー ---------- */

.app-header { background: var(--header-bg); color: #f3ede2; padding: 10px 26px; display: flex; align-items: center; gap: 14px; box-shadow: 0 2px 12px rgba(31, 26, 18, .18); position: sticky; top: 0; z-index: 30; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #c08d4c, #8a5e2c); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 19px; color: #fff; flex: none; }
.brand-title { font-size: 16px; font-weight: 700; line-height: 1.25; }
.brand-sub { font-size: 11.5px; color: #b9ad9b; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.header-date { font-size: 13px; color: #cdbfa9; }

/* ---------- KPI ---------- */

.app-main { max-width: 1560px; margin: 0 auto; padding: 20px 26px 60px; display: flex; flex-direction: column; gap: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card { padding: 14px 18px; position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--kpi); }
.kpi-num { display: flex; align-items: baseline; gap: 5px; margin: 6px 0 5px; }
.kpi-num .num { font-size: 30px; }
.kpi-unit { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.kpi-rate { font-size: 13px; font-weight: 600; color: #5c8a6a; }
.kpi-sub { font-size: 12px; color: #8a8277; }
.kpi-bar { height: 7px; border-radius: 5px; background: #eef1ee; overflow: hidden; }
.kpi-bar-fill { height: 100%; background: #5c8a6a; border-radius: 5px; transition: width .3s; }
.kpi-alert { cursor: pointer; }
.kpi-alert:hover { border-color: #eecfc7; }

/* ---------- タブ ---------- */

.tabs { display: flex; gap: 6px; border-bottom: 2px solid #e2dccf; padding: 0 2px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { border: 0; background: transparent; font-family: inherit; font-size: 13.5px; font-weight: 700; color: #8a8277; padding: 10px 16px 9px; cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: color .12s; }
.tab-btn:hover { color: var(--ink-2); }
.tab-btn.is-on { color: var(--ink); border-bottom-color: var(--brand); }

/* ---------- マップ ---------- */

.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.map-card { min-width: 0; }
.map-search { width: 220px; height: 34px; font-size: 12.5px; margin-left: auto; }
.map-hits { padding: 8px 18px; background: #faf4ea; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; color: var(--ink-2); }
.map-body { padding: 16px 20px 14px; container-type: inline-size; }

/* セル寸法はマップの入る枠の幅に追従。
   PCでは上段20マス・下段（B6＋仕切り＋A14＝20マス）が横1列に収まるサイズを自動計算する */
.wm { width: 100%; --cell: 34px; }
@supports (width: 1cqw) {
  .wm { --cell: clamp(25px, calc((100cqw - 214px) / 20), 46px); }
  .wm .wm-row { flex-wrap: nowrap; }
}
.wm-frame { position: relative; background: #f7f4ee; border: 2px solid #cbc3b5; border-radius: 16px; padding: 84px 100px 16px 20px; }
.wm-chip { background: #dfe6f0; border: 1px solid #c3cfe0; border-radius: 7px; font-size: 12px; font-weight: 700; color: #4a5c78; display: flex; align-items: center; justify-content: center; text-align: center; position: absolute; }
.wm-door-top { top: -13px; left: 28%; width: 172px; height: 25px; }
.wm-door-left { left: -14px; top: 22%; width: 26px; height: 118px; writing-mode: vertical-rl; }
.wm-dock { right: -15px; top: 18%; width: 28px; height: 150px; writing-mode: vertical-rl; background: #f0ecc9; border-color: #dcd3a8; color: #7a6f36; }
.wm-zoneinfo { position: absolute; left: 32%; top: 16px; font-size: 11.5px; color: #8a8377; line-height: 1.6; }
.wm-zoneinfo b { color: #6f675c; font-size: 12px; }

.wm-temp { border: 1.5px dashed #cf9a5f; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--amber); background: repeating-linear-gradient(45deg, #f7ecd8, #f7ecd8 6px, #fbf4e7 6px, #fbf4e7 12px); text-align: center; cursor: pointer; }
.wm-temp-badge { font-size: 13px; color: #7a5a2a; background: #fff; border: 1px solid #e3cfa8; border-radius: 20px; padding: 2px 10px; }
.wm-temp-abs { position: absolute; right: 8px; bottom: 14px; width: 84px; top: 40%; }
.wm-temp-static { display: none; margin-top: 10px; padding: 12px; }
.wm-temp.is-sel { outline: 2.5px solid var(--brand); outline-offset: 2px; }

.wm-racks { width: 100%; }
.wm-lb { font-size: 12px; font-weight: 600; color: #9a9184; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wm-lb-c { font-weight: 700; color: #6d8299; }
.wm-lb-a { font-weight: 700; color: #c4703f; }
.wm-lb-b { font-weight: 700; color: #cfa24f; }
.wm-lb-sub { color: #a89f92; font-weight: 500; }
.wm-freq-bar { flex: 1; height: 2px; background: linear-gradient(90deg, #cfa24f, #c4703f); border-radius: 2px; margin: 0 6px; min-width: 40px; }
.wm-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; row-gap: 8px; margin-bottom: 15px; }
.wm-row:last-child { margin-bottom: 0; }
.wm-group { display: flex; gap: 4px; flex-wrap: nowrap; }
.wm-divider { width: 2px; height: var(--cell); background: #d8cfc0; margin: 0 6px; border-radius: 2px; }

.wm-cell { border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; cursor: pointer; transition: transform .12s, box-shadow .12s, opacity .12s; user-select: none; width: var(--cell); height: var(--cell); }
.wm-cell:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(31, 26, 18, .18); z-index: 5; }
.wm-cell:focus-visible, .wm-temp:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 1px; }
.wm-cell.is-sel { outline: 2.5px solid var(--brand); outline-offset: 1px; }
.wm-cell.is-hit { outline: 2.5px solid #4a70c0; outline-offset: 1px; box-shadow: 0 0 0 4px #4a70c033; }
.wm-cell.is-dim { opacity: .28; }
.wm-tag { font-size: 8px; color: #a89f92; line-height: 1; }
.wm-serial { font-family: ui-monospace, Menlo, monospace; font-size: calc(var(--cell) * .32); font-weight: 700; color: #3a352e; line-height: 1.1; }
.wm-mark { position: absolute; top: -6px; right: -4px; font-size: 11px; color: var(--alert); }

.wm-footer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.wm-caption { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.wm-legend { display: flex; gap: 13px; flex-wrap: wrap; }
.wm-lg { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #4a453d; }
.wm-sw { width: 15px; height: 15px; border-radius: 4px; }
.wm-hint { margin-left: auto; font-size: 12px; color: #b3aa9c; }

/* ---------- 詳細パネル・アラート ---------- */

.map-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.detail-body { padding: 16px 18px; }
.detail-empty { text-align: center; padding: 18px 10px; color: #b0a897; font-size: 13px; line-height: 1.6; }
.detail-empty-ico { font-size: 30px; margin-bottom: 8px; letter-spacing: 2px; }
.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.detail-id { font-size: 22px; font-weight: 700; }
.detail-close { display: none; margin-left: auto; width: 30px; height: 30px; border: 0; background: rgba(0, 0, 0, .05); border-radius: 8px; font-size: 17px; color: #8a8277; cursor: pointer; }
.detail-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.detail-chips .chip { cursor: default; }
.detail-rows { margin: 8px 0 0; border-top: 1px solid var(--line-soft); }
.detail-rows > div { display: flex; justify-content: space-between; font-size: 13px; padding: 7px 0; }
.detail-rows dt { color: #8a8277; font-weight: 400; }
.detail-rows dd { margin: 0; font-weight: 700; }
.detail-limit { font-weight: 400; color: var(--ink-3); font-size: 11.5px; }
.is-over { color: var(--alert); }
.detail-log { margin-top: 11px; border-top: 1px solid var(--line-soft); padding-top: 11px; }
.detail-log .lbl { margin-bottom: 7px; }
.detail-log-row { display: flex; gap: 8px; font-size: 12px; align-items: baseline; padding: 3px 0; }
.detail-log .linklike { margin-top: 8px; }
.detail-actions { display: flex; gap: 9px; margin-top: 15px; flex-wrap: wrap; }
.detail-actions .btn { flex: 1; min-width: 90px; }
.detail-note { text-align: center; padding: 14px 10px; color: #b0a897; font-size: 13px; line-height: 1.6; }

.temp-lots { display: flex; flex-direction: column; gap: 9px; }
.temp-lot { border: 1px solid #ece0c9; border-radius: 10px; background: #fdf8ef; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.temp-lot-info { min-width: 0; display: flex; flex-direction: column; }
.temp-lot-info b { font-size: 13.5px; }
.temp-lot-info span { font-size: 12px; color: #8a8277; }
.temp-lot .btn { margin-left: auto; flex: none; }

.alert-card { border-color: #eecfc7; }
.alert-card .ch { border-color: #f7e3dd; }
.alert-badge { margin-left: auto; font-size: 11.5px; color: var(--alert); background: #fae9e5; padding: 2px 10px; border-radius: 999px; font-weight: 700; }
.alert-body-wrap { padding: 12px 18px 14px; display: flex; flex-direction: column; gap: 10px; }
.alert-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; border-radius: 8px; padding: 4px 6px; margin: -4px -6px; }
.alert-row:hover { background: #fdf6f4; }
.alert-loc { font-weight: 700; font-size: 14px; }
.alert-days { text-align: right; }
.alert-days b { color: var(--alert); font-size: 13.5px; }
.alert-days span { display: block; font-size: 10.5px; color: var(--ink-3); }
.alert-note { font-size: 11.5px; color: var(--ink-3); border-top: 1px solid var(--line-soft); padding-top: 10px; line-height: 1.55; }

/* ---------- 在庫一覧 ---------- */

.inv-search { width: 210px; height: 34px; font-size: 12.5px; margin-left: auto; }
.inv-temp { padding: 10px 18px 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inv-temp:empty { display: none; }
.inv-temp-head { font-size: 12px; font-weight: 700; color: var(--amber); }
.inv-temp .chip { cursor: default; }
#inv-tbody tr[data-jump] { cursor: pointer; }
#inv-tbody tr[data-jump]:hover td { background: #faf7f1; }
.zone-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }
.inv-foot { padding: 9px 18px; border-top: 1px solid var(--line-soft); }

/* ---------- 履歴 ---------- */

.hist-filters { padding: 11px 16px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.v-sep { width: 1px; height: 20px; background: #e6ddd0; }
.hist-search { margin-left: auto; width: 220px; height: 34px; font-size: 12.5px; }
.hist-loc-strip { padding: 8px 16px; background: #faf4ea; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.hist-loc-strip .linklike { margin-left: auto; }

/* ---------- 分析 ---------- */

.ana-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.bar-row { display: flex; flex-direction: column; gap: 5px; }
.bar-head { display: flex; justify-content: space-between; font-size: 12.5px; }
.bar-track { height: 8px; border-radius: 5px; background: #efeae1; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width .3s; }
.op-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; flex-wrap: wrap; }
.op-ini { width: 26px; height: 26px; border-radius: 50%; background: #efe8db; color: var(--ink-2); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex: none; }
.op-name { font-weight: 600; min-width: 46px; }
.op-total { margin-left: auto; font-weight: 700; }

.month-nav { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; font-weight: 600; }
.month-btn { border: 1px solid #ddd6ca; background: #faf8f4; border-radius: 7px; width: 26px; height: 26px; font-size: 10px; color: var(--ink-2); cursor: pointer; }
.month-btn:hover { background: #f1ece1; }
.mchart-legend { display: flex; gap: 14px; font-size: 12px; }
.mchart-legend span { display: flex; align-items: center; gap: 6px; }
.mchart-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.mchart { display: flex; align-items: flex-end; gap: 10px; min-height: 150px; overflow-x: auto; padding-bottom: 2px; }
.mchart-day { flex: 1; min-width: 34px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mchart-cols { height: 118px; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.mchart-bar { width: 38%; max-width: 16px; border-radius: 3px 3px 0 0; position: relative; }
.mchart-in { background: var(--green); }
.mchart-out { background: var(--red); }
.mchart-bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fbf8f1; font-size: 11px; padding: 4px 9px; border-radius: 6px; white-space: nowrap; z-index: 10; }
.mchart-lb { font-size: 10.5px; color: var(--ink-3); }
.mchart-foot { display: flex; gap: 26px; border-top: 1px solid var(--line-soft); margin-top: 14px; padding-top: 13px; }
.mchart-total { font-size: 22px; margin-top: 3px; }

/* ---------- モーダル ---------- */

/* モーダルは「ヘッダー固定＋本文のみ内部スクロール」。
   画面より背が高くなっても本文スクロールで全項目に到達できる */
.modal-overlay { position: fixed; inset: 0; background: rgba(30, 24, 17, .5); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 32px 20px; overflow: hidden; }
.modal { width: 680px; max-width: 100%; overflow: hidden; animation: modal-in .16s ease-out; display: flex; flex-direction: column; max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px); }
.modal-wide { width: 880px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 22px; background: #f1eee7; border-bottom: 1px solid #e6ddd0; flex: none; }
.modal-in .modal-head { background: #eef4ef; border-color: #dbe7de; }
.modal-out .modal-head { background: #f8ede8; border-color: #eeddd4; }
.modal-ico { width: 34px; height: 34px; border-radius: 9px; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 700; flex: none; }
.modal-title .ct { font-size: 16px; }
.modal-x { margin-left: auto; width: 32px; height: 32px; border: 0; background: rgba(0, 0, 0, .05); border-radius: 8px; font-size: 19px; color: #8a8277; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 17px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; min-height: 0; }
.modal-foot { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line-soft); padding-top: 16px; flex-wrap: wrap; }
.modal-foot-btns { margin-left: auto; display: flex; gap: 10px; }
.form-err { background: #fae9e5; border: 1px solid #eecfc7; color: #a03f2e; border-radius: 9px; padding: 9px 13px; font-size: 13px; font-weight: 600; }

.io-toggle { display: flex; gap: 10px; }
.io-btn { flex: 1; height: 52px; border: 1.5px solid #e2dccf; border-radius: 12px; background: #faf8f4; color: #8a8277; font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit; transition: all .12s; }
.io-btn.is-on-in { background: var(--green); border-color: var(--green); color: #fff; }
.io-btn.is-on-out { background: var(--red); border-color: var(--red); color: #fff; }

.loc-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.loc-row .flbl { margin: 0; }
.loc-row .seg { margin-left: auto; }
.loc-line { display: flex; gap: 10px; align-items: center; }
.loc-select { flex: 1; height: 46px; font-size: 15px; font-weight: 600; min-width: 0; }
.occ-strip { margin-top: 9px; border: 1px solid; border-radius: 10px; padding: 11px 14px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.occ-tag { font-size: 11px; font-weight: 700; white-space: nowrap; }
.occ-body { font-size: 13.5px; color: #3a352e; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 16px; }
.form-span { grid-column: 1 / -1; }
.form-grid .fld, .form-grid select { height: 44px; }
.form-grid textarea.fld { height: auto; resize: vertical; }

.stepper { display: flex; align-items: center; border: 1px solid #ddd6ca; border-radius: 9px; overflow: hidden; height: 44px; width: 150px; background: #fff; }
.step-btn { width: 44px; height: 100%; border: 0; background: #f7f4ee; font-size: 20px; color: var(--ink-2); cursor: pointer; flex: none; }
.step-btn:first-child { border-right: 1px solid #eee6da; }
.step-btn:last-child { border-left: 1px solid #eee6da; }
.step-input { flex: 1; width: 40px; min-width: 0; border: 0; text-align: center; font-size: 17px; font-weight: 700; font-family: inherit; -moz-appearance: textfield; }
.step-input::-webkit-outer-spin-button, .step-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.step-input:focus { outline: none; background: #fdf9f2; }

.move-src { border: 1px solid #ece0c9; border-radius: 10px; background: #fdf8ef; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.move-src b { font-size: 15px; }

.tally-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tally-who { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: 12px; color: #8a8277; }
.tally-who .fld { height: 36px; width: 110px; }
.tally-scroll { max-height: 52vh; overflow: auto; border: 1px solid var(--line-soft); border-radius: 10px; }
.tally-tbl { min-width: 640px; }
.tally-tbl .stepper { height: 34px; width: 116px; display: inline-flex; }
.tally-tbl .step-btn { width: 32px; font-size: 16px; }
.tally-tbl .step-input { font-size: 14px; }

.set-sec { border-top: 1px solid var(--line-soft); padding-top: 16px; }
.set-sec:first-child { border-top: 0; padding-top: 0; }
.set-sec > .flbl { margin-bottom: 9px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.master-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid #ded7cb; background: #faf8f4; border-radius: 999px; padding: 6px 8px 6px 13px; font-size: 13px; }
.chip-x { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #efe6d6; color: #9a7a4a; cursor: pointer; font-size: 13px; line-height: 1; }
.chip-x:hover { background: #e5d8bf; }
.set-add { display: flex; gap: 10px; }
.set-add .fld { flex: 1; height: 42px; min-width: 0; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.set-row + .set-row { border-top: 1px dashed #eee6da; }
.set-row > div:first-child { flex: 1; }
.set-row-t { font-size: 13.5px; font-weight: 600; }

/* ---------- FAB・トースト ---------- */

.fab { display: none; position: fixed; right: 18px; bottom: 20px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 27px; font-weight: 700; box-shadow: 0 6px 20px rgba(31, 26, 18, .35); cursor: pointer; z-index: 40; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 80px); background: var(--ink); color: #fbf8f1; border-radius: 12px; padding: 12px 18px; font-size: 13.5px; display: flex; align-items: center; gap: 14px; box-shadow: 0 8px 28px rgba(31, 26, 18, .4); z-index: 60; transition: transform .22s ease; max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); }
.toast button { border: 0; background: #55483a; color: #ffd9a8; border-radius: 8px; padding: 6px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: inherit; white-space: nowrap; }
.toast button:hover { background: #665744; }

/* ---------- 写真 ---------- */

.photo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo-btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.photo-preview { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.photo-box { margin: 10px 0 2px; }
.photo-thumb { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; background: #f4f1ea; min-height: 60px; }
.photo-ops { display: flex; gap: 8px; margin-top: 7px; }
.photo-add-btn { display: block; width: 100%; margin: 10px 0 2px; border: 1.5px dashed #d5cbb9; border-radius: 11px; background: #faf8f4; color: var(--ink-2); font-family: inherit; font-size: 13px; font-weight: 600; padding: 11px 12px; cursor: pointer; text-align: center; }
.photo-add-btn:hover { background: #f4efe6; }
.temp-lot-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 9px; border: 1px solid #ece0c9; cursor: zoom-in; flex: none; background: #f4f1ea; }
.temp-lot-addphoto { width: 44px; height: 44px; border: 1.5px dashed #d9c8a8; border-radius: 9px; background: #fdf8ef; color: var(--amber); cursor: pointer; flex: none; font-size: 15px; line-height: 1.1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.temp-lot-addphoto span { font-size: 10px; font-weight: 700; }
.hist-img-btn { border: 1px solid #ded7cb; background: #faf8f4; border-radius: 7px; padding: 2px 7px; font-size: 12px; cursor: pointer; vertical-align: baseline; }
.hist-img-btn:hover { background: #f1ece1; }
.lightbox { position: fixed; inset: 0; background: rgba(20, 16, 11, .82); z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: min(94vw, 1100px); max-height: 84vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.lightbox-hint { color: #cdbfa9; font-size: 12.5px; }

/* ---------- ログイン・読み込み ---------- */

.login-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.login-card { width: 380px; max-width: 100%; padding: 32px 28px 26px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.login-mark { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; }
.login-title { font-size: 17px; font-weight: 700; }
.login-sub { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.login-input { width: 100%; height: 46px; text-align: center; font-size: 16px; letter-spacing: .1em; }
.login-btn { width: 100%; height: 44px; font-size: 14.5px; }
.login-note { font-size: 11.5px; color: var(--ink-3); }
.login-card .form-err { width: 100%; }

.app-loading { position: fixed; inset: 0; background: rgba(240, 237, 231, .7); display: flex; align-items: center; justify-content: center; z-index: 90; }
.app-loading-box { background: var(--ink); color: #fbf8f1; border-radius: 12px; padding: 12px 22px; font-size: 13.5px; box-shadow: 0 8px 28px rgba(31, 26, 18, .3); }

/* ---------- レスポンシブ ---------- */

@media (max-width: 1250px) {
  .map-layout { grid-template-columns: 1fr; }
}
@media (max-width: 1080px) {
  .ana-grid { grid-template-columns: 1fr; margin-bottom: 16px; }
}

/* マップのみ861px以下で簡易配置（棚グループ折返し・一時置き場を下に） */
@media (max-width: 860px) {
  .wm { --cell: 36px !important; }
  .wm .wm-row { flex-wrap: wrap; }
  .wm-group { flex-wrap: wrap; }
  .wm-frame { padding: 64px 4% 14px 4%; }
  .wm-zoneinfo { display: none; }
  .wm-door-top { width: 120px; left: 24%; }
  .wm-dock { height: 110px; top: 12%; }
  .wm-door-left { height: 90px; }
  .wm-temp-abs { display: none; }
  .wm-temp-static { display: flex; }
  .wm-hint { display: none; }
}

@media (max-width: 760px) {
  .app-header { padding: 8px 14px; gap: 10px; }
  .brand-sub, .header-date { display: none; }
  .brand-title { font-size: 14px; }
  .btn-label { display: none; }
  .header-right .btn { padding: 9px 12px; }
  .app-main { padding: 14px 12px 80px; gap: 12px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-num .num { font-size: 25px; }
  .ch { padding: 12px 14px; }
  .map-search, .inv-search, .hist-search { width: 100%; margin-left: 0; order: 5; }
  .map-body { padding: 12px 12px 10px; }

  /* 詳細パネルはボトムシート化 */
  .detail-card { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(31, 26, 18, .3); max-height: 72vh; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; transform: translateY(105%); transition: transform .22s ease; }
  .detail-card.has-sel { transform: translateY(0); }
  .detail-card .ch { display: none; }
  .detail-close { display: block; }
  .detail-body { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }

  .fab { display: block; bottom: calc(20px + env(safe-area-inset-bottom)); }
  .tbl-scroll { max-height: none; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* モーダルは全幅のボトムシート。本文は内部スクロール */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { animation: none; width: 100%; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 18px 18px 0 0; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px 14px calc(18px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: 1fr; gap: 13px; }
  .mchart-day { min-width: 30px; }
  .hist-filters { padding: 10px 12px; }

  /* iOSはfont-size16px未満の入力欄でフォーカス時に自動ズームするため16pxに統一 */
  .fld, .map-search, .inv-search, .hist-search, .step-input { font-size: 16px; }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .loc-row { flex-wrap: wrap; }
  .loc-row .seg { margin-left: 0; }
  .modal-foot-btns { width: 100%; }
  .modal-foot-btns .btn { flex: 1; padding: 12px 16px; }
  .io-btn { height: 56px; }
  .detail-actions .btn { padding: 12px 16px; }
  .tally-scroll { max-height: 46vh; }
  .month-nav { margin-left: 0; }
  .photo-thumb { max-height: 220px; }
}

@media (max-width: 420px) {
  .wm { --cell: 32px !important; }
}

/* ---------- 印刷（レポートページ用の共通部品は report.html 内で上書き） ---------- */

@media print {
  .app-header, .tabs, .fab, .toast, .map-search, .wm-hint { display: none !important; }
}
