/* 猪野組 備品管理アプリ — 配色は inogumi.pages.dev と同じロゴ実測値 */
:root {
  --red: #EB072A;
  --red-dark: #C00622;
  --dark: #4F4F4F;
  --gray: #CACACA;
  --safety-yellow: #F5C400;
  --bg-soft: #F7F6F2;
  --text: #3A3A3A;
  --white: #FFFFFF;
  --done: #2E7D32;
  --warn-bg: #FFF6D9;
  --warn-fg: #8A6D00;
  --danger-bg: #FDE7E9;
  --danger-fg: #C62828;
  --repair-bg: #FFF0E0;
  --repair-fg: #E65100;
  --line: #E3E0D8;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
button { font-family: inherit; }

/* ---------- ヘッダー ---------- */
header.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--white);
  border-bottom: 3px solid var(--red);
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.app-title { font-size: 17px; font-weight: 700; color: var(--dark); display: flex; align-items: center; gap: 7px; }
.app-title .logo-mark {
  background: var(--red); color: #fff; border-radius: 6px;
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.header-spacer { flex: 1; }
.person-badge {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; color: var(--dark); white-space: nowrap;
}
.btn-refresh {
  border: 1px solid var(--line); background: var(--white); border-radius: 8px;
  width: 36px; height: 36px; font-size: 16px; cursor: pointer;
}

/* ---------- ナビ（スマホ＝下固定／PC＝ヘッダー下） ---------- */
nav.app-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--white); border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
nav.app-nav button {
  flex: 1; border: none; background: none; cursor: pointer;
  padding: 7px 2px 6px; font-size: 11px; color: #888;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav.app-nav button .nav-icon { font-size: 20px; line-height: 1; }
nav.app-nav button.active { color: var(--red); font-weight: 700; }

main.app-main { padding: 14px 14px 84px; max-width: 1080px; margin: 0 auto; }

@media (min-width: 820px) {
  nav.app-nav {
    position: sticky; top: 59px; bottom: auto;
    border-top: none; border-bottom: 1px solid var(--line);
    justify-content: center; gap: 6px; padding: 4px 0;
  }
  nav.app-nav button { flex: 0 0 auto; flex-direction: row; font-size: 14px; padding: 9px 18px; gap: 7px; border-radius: 8px; }
  nav.app-nav button.active { background: #FCEBEE; }
  main.app-main { padding-bottom: 40px; }
}

/* ---------- 汎用 ---------- */
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.view-title { font-size: 18px; font-weight: 700; color: var(--dark); margin: 4px 0 12px; }
.muted { color: #888; font-size: 13px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; cursor: pointer;
  font-size: 15px; font-weight: 700; padding: 12px 18px;
  min-height: 44px;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:active { background: var(--red-dark); }
.btn-outline { background: var(--white); color: var(--dark); border: 1.5px solid var(--gray); }
.btn-small { padding: 7px 12px; min-height: 36px; font-size: 13px; border-radius: 8px; }
.btn-danger-text { background: none; border: none; color: var(--danger-fg); font-size: 13px; cursor: pointer; text-decoration: underline; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; }

/* ---------- ログイン ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 380px; text-align: center; }
.login-logo {
  width: 64px; height: 64px; border-radius: 16px; background: var(--red); color: #fff;
  font-size: 34px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.login-box h1 { font-size: 21px; color: var(--dark); margin: 0 0 4px; }
.login-box .sub { color: #888; font-size: 13px; margin-bottom: 22px; }

/* ---------- フォーム ---------- */
.field { margin-bottom: 14px; text-align: left; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--dark); margin-bottom: 5px; }
.field label .req { color: var(--red); font-size: 11px; margin-left: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--gray); border-radius: 10px;
  padding: 11px 12px; font-size: 16px; background: var(--white); color: var(--text);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--red);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

/* ---------- 検索・一覧 ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.search-bar input {
  flex: 1; border: 1.5px solid var(--gray); border-radius: 999px;
  padding: 11px 18px; font-size: 16px; background: var(--white);
}
.search-bar input:focus { outline: none; border-color: var(--red); }
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-row select {
  flex: 1; min-width: 100px; border: 1.5px solid var(--line); border-radius: 8px;
  padding: 8px 6px; font-size: 13px; background: var(--white); color: var(--dark);
}
.count-line { font-size: 13px; color: #888; margin-bottom: 8px; }

.item-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
}
.item-card:active { background: #FAF8F4; }
.item-name { font-size: 16px; font-weight: 700; color: var(--dark); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-qty { font-size: 13px; color: #888; font-weight: 400; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.badge {
  font-size: 12px; border-radius: 6px; padding: 2px 8px;
  background: var(--bg-soft); border: 1px solid var(--line); color: #666;
}
.badge.loc { background: #EDF3FA; border-color: #C9DCF0; color: #1D5A99; }
.badge.holder { background: #F0EDFA; border-color: #D8D0F0; color: #5A44A8; }
.badge.st-ok { background: #EAF4EB; border-color: #C4E0C7; color: var(--done); }
.badge.st-warn { background: var(--warn-bg); border-color: #EAD98F; color: var(--warn-fg); }
.badge.st-danger { background: var(--danger-bg); border-color: #F2BFC4; color: var(--danger-fg); }
.badge.st-repair { background: var(--repair-bg); border-color: #F2CFA8; color: var(--repair-fg); }
.badge.st-gone { background: #EEE; border-color: #DDD; color: #999; }

.empty-note { text-align: center; color: #999; padding: 40px 10px; font-size: 14px; }

/* ---------- 詳細 ---------- */
.detail-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.detail-table th, .detail-table td {
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line);
  font-size: 14px; vertical-align: top;
}
.detail-table th { width: 7.5em; color: #888; font-weight: 600; white-space: nowrap; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 6px; }
.history-list { list-style: none; margin: 8px 0 0; padding: 0; }
.history-list li { border-left: 3px solid var(--line); padding: 6px 0 6px 12px; margin-left: 4px; }
.history-list .h-head { font-size: 13px; font-weight: 700; color: var(--dark); }
.history-list .h-detail { font-size: 13px; color: #666; overflow-wrap: anywhere; }
.history-list .h-time { font-size: 11px; color: #AAA; }
.back-link { background: none; border: none; color: #888; font-size: 14px; cursor: pointer; padding: 4px 0; margin-bottom: 6px; }

/* ---------- 集計 ---------- */
.sum-table { width: 100%; border-collapse: collapse; }
.sum-table th, .sum-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); font-size: 14px; text-align: left; }
.sum-table td.num, .sum-table th.num { text-align: right; }
.sum-table tr.total-row th, .sum-table tr.total-row td { font-weight: 700; color: var(--dark); border-top: 2px solid var(--dark); }

/* ---------- 設定 ---------- */
.master-list { list-style: none; margin: 6px 0; padding: 0; }
.master-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.master-list li span.m-name { flex: 1; overflow-wrap: anywhere; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; border: 1.5px solid var(--gray); border-radius: 8px; padding: 9px 10px; font-size: 15px; }

/* ---------- モーダル ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--white); width: 100%; max-width: 520px;
  border-radius: 16px 16px 0 0; padding: 18px 16px 24px;
  max-height: 88vh; overflow-y: auto;
}
@media (min-width: 820px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 16px; }
}
.modal h3 { margin: 0 0 14px; font-size: 17px; color: var(--dark); }
.modal-btns { display: flex; gap: 10px; margin-top: 6px; }
.modal-btns .btn { flex: 1; }

/* ---------- トースト ---------- */
#toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%);
  background: var(--dark); color: #fff; font-size: 14px;
  padding: 10px 20px; border-radius: 999px; z-index: 60;
  opacity: 0; transition: opacity .25s; pointer-events: none;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
@media (min-width: 820px) { #toast { bottom: 40px; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
