/* =========================================================
   在庫一覧（トップ）  資材・商品のボタン型カード
   ========================================================= */

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 16px; }
.kpi {
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    padding: 8px 11px; display: flex; flex-direction: column; gap: 1px;
}
.kpi-lbl { font-size: 11px; color: var(--ink-sub); }
.kpi-val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-val em { font-style: normal; font-size: 11px; font-weight: 400; color: var(--ink-sub); margin-left: 3px; }
.kpi-alert { border-color: #e8b4b4; background: #fdf3f3; }
.kpi-alert .kpi-val { color: var(--red); }
.kpi-warn { border-color: #f0d9a8; background: var(--tint-warm); }
.kpi-warn .kpi-val { color: var(--amber); }

/* ---------- セクション見出し ---------- */
.sec-hd { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 0 0 9px; }
.sec-hd h3 { margin: 0; font-size: 14px; }
.sec-hd h3 span { font-weight: 400; font-size: 11.5px; color: var(--ink-sub); margin-left: 8px; }
.sec-tools { margin-left: auto; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.sec-tools .btn { text-decoration: none; }
.sec-tools input[type=text] { width: 200px; }
.chk { font-size: 12px; display: flex; align-items: center; gap: 4px; }

/* ---------- 種別チップ ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
    --chip: var(--ink-sub);
    background: #fff; border: 1px solid var(--line-dark); border-radius: 14px;
    padding: 3px 12px; font: inherit; font-size: 12px; color: var(--chip); cursor: pointer;
}
.chip:hover { background: #f2f2ee; }
.chip.is-on { background: var(--chip); border-color: var(--chip); color: #fff; }
.chip[data-kind=""] { --chip: #333; }

/* ---------- タイル ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 9px; }
.tile {
    --kc: #999;
    position: relative; text-align: left; font: inherit; cursor: pointer;
    background: #fff; border: 1px solid var(--line-dark); border-left: 4px solid var(--kc);
    border-radius: 8px; padding: 9px 11px 10px;
    display: flex; flex-direction: column; gap: 3px;
    transition: box-shadow .12s, transform .08s;
}
.tile:hover { box-shadow: 0 4px 14px rgba(0,0,0,.13); transform: translateY(-1px); }
.tile:active { transform: translateY(0); }
.tile.is-warn { background: var(--tint-warm); }
.tile.is-low  { background: #fdf3f3; border-color: #e8b4b4; }

.t-top { display: flex; align-items: center; gap: 6px; }
.t-kind { font-size: 10px; color: var(--kc); border: 1px solid currentColor; border-radius: 3px; padding: 0 5px; }
.t-flag { font-size: 10px; border-radius: 3px; padding: 0 5px; color: #fff; margin-left: auto; }
.flag-low  { background: var(--red); }
.flag-warn { background: var(--amber); }

.t-name { font-weight: 700; font-size: 13px; line-height: 1.35; }
.t-num { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.t-num em { font-style: normal; font-size: 11px; font-weight: 400; color: var(--ink-sub); margin-left: 3px; }

.t-split { display: flex; gap: 10px; font-size: 11px; color: var(--ink-sub); }
.t-split b { color: var(--ink); font-variant-numeric: tabular-nums; }

.t-bar { display: block; height: 4px; background: #ecece6; border-radius: 2px; overflow: hidden; margin: 3px 0 1px; }
.t-bar i { display: block; height: 100%; background: var(--kc); }
.is-low .t-bar i  { background: var(--red); }
.is-warn .t-bar i { background: var(--amber); }

.t-foot { font-size: 10.5px; color: var(--ink-sub); }

.t-stores { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 1px; }
.st-pill {
    font-size: 10.5px; background: #f4f4ef; border: 1px solid var(--line);
    border-radius: 10px; padding: 0 7px; white-space: nowrap;
}
.st-pill b { font-variant-numeric: tabular-nums; }
.st-pill.bad { background: #fdecec; border-color: #e8b4b4; color: var(--red); }

/* ---------- モーダル内のロット行 ---------- */
.lot-row {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; margin-bottom: 7px;
}
.lot-row .lot-main { flex: 1; min-width: 0; }
.lot-row .lot-name { font-weight: 700; }
.lot-row .lot-meta { font-size: 11px; color: var(--ink-sub); }
.lot-row .lot-qty { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.lot-row.exp-soon { border-color: #e8b4b4; background: #fdf3f3; }
.exp-tag { font-size: 10px; color: var(--red); border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; margin-left: 5px; }
.op-grid { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.sub-hd { font-size: 12px; font-weight: 700; margin: 12px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.sub-hd:first-child { margin-top: 0; }

/* =========================================================
   店舗ページ
   ========================================================= */
.store-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.store-tab {
    position: relative; text-decoration: none; color: var(--ink);
    background: #fff; border: 1px solid var(--line-dark); border-radius: 8px;
    padding: 7px 14px 7px 12px; min-width: 132px;
    display: flex; flex-direction: column; gap: 0;
}
.store-tab:hover { background: #f2f2ee; }
.store-tab.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.store-tab .stt-name { font-weight: 700; font-size: 13.5px; }
.store-tab .stt-sub { font-size: 10.5px; color: var(--ink-sub); }
.store-tab.is-on .stt-sub { color: rgba(255,255,255,.7); }
.store-tab .stt-badge {
    position: absolute; right: 6px; top: 6px;
    min-width: 17px; text-align: center; font-size: 10px; padding: 0 4px;
    border-radius: 9px; background: var(--red); color: #fff;
}

.shop-hd { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.shop-hd-tools { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }
.shop-hd-tools .btn { text-decoration: none; }

.shop-cols { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.shop-cols > div    { flex: 1 1 560px; min-width: 0; }
.shop-cols > aside  { flex: 0 0 280px; }
@media (max-width: 900px) { .shop-cols > aside { flex: 1 1 100%; } }

/* 履歴ボックス（map.css を読まないページ用） */
.side-box {
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    padding: 10px; margin-bottom: 12px; max-height: 420px; overflow: auto;
}
.hist-row { border-bottom: 1px dotted var(--line); padding: 4px 0; font-size: 11.5px; }
.hist-row:last-child { border-bottom: 0; }
.hist-at { color: var(--ink-sub); font-size: 10.5px; }
.hist-qty.plus  { color: var(--green); }
.hist-qty.minus { color: var(--red); }
