/* =========================================
   全体ベース設定（スマホアプリ風・文字大きめ）
========================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #f3f4f6;
  color: #111827;
  line-height: 1.6;
  font-size: 17px;
}

@media (min-width: 960px) {
  body {
    font-size: 16px;
  }
}

/* =========================================
   ヘッダー / ナビ
========================================= */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  margin-right: 0.75rem;
  white-space: nowrap;
}

#nav {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.2rem 0;
  flex: 1;
}

#nav::-webkit-scrollbar {
  height: 4px;
}

#nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 999px;
}

#nav .link {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.16);
  color: #eff6ff;
  cursor: pointer;
  white-space: nowrap;
}

#nav .link:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* =========================================
   メイン / ページ共通
========================================= */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 4rem;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page h1 {
  font-size: 1.35rem;
  margin: 0 0 0.75rem;
  color: #111827;
}

/* =========================================
   アラート
========================================= */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.error-text {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

#nav .link.active {
  background: rgba(255, 255, 255, 0.35);
  font-weight: 600;
}

a.home-tile {
  text-decoration: none;
  color: inherit;
}

a.ghost,
a.primary,
a.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  border: none;
  cursor: pointer;
  min-height: 2.4rem;
}

a.ghost {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
}

a.ghost:hover {
  background: #f9fafb;
}

/* =========================================
   カード / レイアウト
========================================= */
.card {
  background: #ffffff;
  border-radius: 18px;
  padding: 1rem 1rem 0.9rem;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.08),
    0 4px 12px rgba(15, 23, 42, 0.06);
}

.card+.card {
  margin-top: 0.75rem;
}

.card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: #1f2937;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.row .grow {
  flex: 1;
}

@media (max-width: 640px) {
  .row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* =========================================
   テキスト
========================================= */
.muted {
  color: #6b7280;
}

.small {
  font-size: 0.85rem;
}

/* =========================================
   フォーム要素
========================================= */
label {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.95rem;
}

label:first-of-type {
  margin-top: 0.1rem;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 1rem;
  outline: none;
  background: #ffffff;
}

input:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

textarea {
  resize: vertical;
  min-height: 2.2em;
}

/* =========================================
   ボタン
========================================= */
button {
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  border: none;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.1s ease, background 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
}

button:active {
  transform: scale(0.98);
}

button.small {
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  min-height: 2.1rem;
}

button.primary {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

button.primary:hover {
  background: #1d4ed8;
}

button.secondary {
  background: #e0f2fe;
  color: #0f172a;
}

button.secondary:hover {
  background: #bfdbfe;
}

button.ghost {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
}

button.ghost:hover {
  background: #f9fafb;
}

button.danger {
  background: #ef4444;
  color: #ffffff;
}

button.danger:hover {
  background: #dc2626;
}

/* =========================================
   テーブル
========================================= */
.table-wrap {
  margin-top: 0.5rem;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.simple {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  font-size: 0.95rem;
}

table.simple th,
table.simple td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

table.simple thead {
  background: #eff6ff;
}

table.simple th {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1f2937;
}

table.simple tbody tr:nth-child(even) {
  background: #f9fafb;
}

/* =========================================
   ホームダッシュボード
========================================= */
.home-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 18px;
}

@media (max-width: 720px) {
  .home-dashboard {
    grid-template-columns: 1fr;
  }
}

.home-tile {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: #ffffff;
  border-radius: 14px;
  padding: 18px 20px 16px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.14);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.home-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
}

.tile-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tile-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.tile-title {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: #0f172a;
  flex: 1 1 auto;
}

.tile-badge {
  flex: 0 0 auto;
  background: #d21b4b;
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(210, 27, 75, 0.22);
  white-space: nowrap;
}

.tile-desc {
  margin-top: 10px;
  font-size: 14px;
  color: rgba(15, 23, 42, 0.70);
}

/* =========================================
   ユーザー情報・ナビトグル
========================================= */
.user-info {
  margin-left: 0.75rem;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0.9;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  border: none;
  background: transparent;
  color: #eff6ff;
  font-size: 1.2rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
  }

  #nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #2563eb, #1d4ed8);
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    display: none;
  }

  #nav.open {
    display: flex;
  }

  .user-info {
    display: none;
  }
}

/* =========================================
   フッター
========================================= */
.footer {
  text-align: center;
  padding: 0.75rem 0;
  color: #9ca3af;
  font-size: 0.8rem;
}

/* =========================================
   スマホ調整
========================================= */
@media (max-width: 640px) {
  main {
    padding: 0.6rem 0.6rem 3.5rem;
  }

  .page h1 {
    font-size: 1.25rem;
  }

  .card {
    padding: 0.9rem 0.85rem 0.85rem;
    border-radius: 16px;
  }

  table.simple {
    font-size: 0.9rem;
  }

  button {
    width: 100%;
  }
}

/* =========================================
   スキャナー関連
========================================= */

/* スキャン入力グループ */
.scan-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.scan-input-group input {
  flex: 1;
}

.scan-btn {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-size: 1.2rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin-top: 0.25rem;
}

.scan-btn:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

.scan-btn:active {
  transform: scale(0.95);
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-content {
  background: #ffffff;
  border-radius: 20px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(15, 23, 42, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #111827;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid #e5e7eb;
  justify-content: flex-end;
}

/* スキャナーコンテナ */
.scanner-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-frame {
  width: 70%;
  height: 50%;
  border: 3px solid rgba(37, 99, 235, 0.8);
  border-radius: 12px;
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.5),
    inset 0 0 20px rgba(37, 99, 235, 0.3);
  animation: scannerPulse 2s ease-in-out infinite;
}

@keyframes scannerPulse {

  0%,
  100% {
    border-color: rgba(37, 99, 235, 0.8);
  }

  50% {
    border-color: rgba(37, 99, 235, 1);
  }
}

.scan-info {
  margin-top: 1rem;
  text-align: center;
}

.scan-result-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2563eb;
  margin: 0.5rem 0;
  word-break: break-all;
}

.scan-result {
  padding: 1rem;
  background: #f0f9ff;
  border-radius: 12px;
  border: 1px solid #bfdbfe;
}

@media (max-width: 640px) {
  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .scanner-container {
    aspect-ratio: 3 / 4;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer button {
    width: 100%;
  }
}

/* =========================================
   付属品セクション
========================================= */
.accessories-section {
  margin-top: 0.75rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.accessories-section>label {
  margin-top: 0;
  font-weight: 600;
  color: #374151;
}

.accessories-list {
  margin-top: 0.5rem;
}

.accessory-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.accessory-item input {
  flex: 1;
  margin-top: 0;
}

.accessory-item .remove-accessory {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.accessory-item .remove-accessory:hover {
  background: #dc2626;
}

#pm-add-accessory {
  margin-top: 0.5rem;
}

.accessories-section.hidden {
  display: none;
}

/* 付属品チェックリスト */
.accessories-checklist {
  margin-top: 0.5rem;
}

.accessories-checklist-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.accessories-checklist-item:last-child {
  border-bottom: none;
}

.accessories-checklist-item input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.accessories-checklist-item label {
  margin: 0;
  cursor: pointer;
  flex: 1;
}

.accessories-checklist-empty {
  color: #6b7280;
  font-size: 0.9rem;
  font-style: italic;
}