* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f9;
  color: #1e293b;
  min-height: 100vh;
}

header {
  background: #2563eb;
  color: #fff;
  padding: 16px 20px;
  text-align: center;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 検索 */
.search-section input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
}

.search-section input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* フォームセクション */
.form-section,
.list-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.form-section h2,
.list-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1e293b;
}

.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.req {
  color: #ef4444;
  margin-left: 2px;
}

.form-group input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #f8fafc;
  transition: border-color 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* ボタン */
.btn-primary {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #e2e8f0;
  color: #1e293b;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

/* バッジ */
.count-badge {
  background: #2563eb;
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

/* 品目カード */
.item-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #f1f5f9;
  cursor: pointer;
  gap: 8px;
}

.item-header:hover {
  background: #e2e8f0;
}

.item-name {
  font-weight: 700;
  font-size: 1rem;
  color: #1e293b;
  flex: 1;
}

.item-meta {
  font-size: 0.8rem;
  color: #64748b;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
  line-height: 1;
}

.btn-icon:hover {
  background: #cbd5e1;
}

.btn-icon.red:hover {
  background: #fee2e2;
}

.toggle-icon {
  font-size: 0.8rem;
  color: #64748b;
  transition: transform 0.2s;
}

.toggle-icon.open {
  transform: rotate(180deg);
}

/* 品目詳細 */
.item-body {
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
}

.main-supplier-info {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.88rem;
}

.main-supplier-info .label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #2563eb;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.main-supplier-info p {
  color: #1e293b;
  margin: 2px 0;
}

/* 代替仕入れ先 */
.alt-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-add-alt {
  background: #dbeafe;
  color: #2563eb;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-add-alt:hover {
  background: #bfdbfe;
}

.alt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alt-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  position: relative;
}

.alt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.alt-name {
  font-weight: 700;
  color: #1e293b;
}

.alt-info {
  color: #475569;
  margin: 2px 0;
  font-size: 0.83rem;
}

.no-alt {
  color: #94a3b8;
  font-size: 0.85rem;
  text-align: center;
  padding: 8px 0;
}

.empty-state {
  text-align: center;
  color: #94a3b8;
  padding: 32px 16px;
  font-size: 0.95rem;
}

/* モーダル */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  width: min(420px, 92vw);
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #64748b;
  padding: 4px 6px;
  border-radius: 6px;
}

.btn-close:hover {
  background: #f1f5f9;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.modal-actions button {
  flex: 1;
  width: auto;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
}

.hidden {
  display: none !important;
}

/* スマホ調整 */
@media (max-width: 480px) {
  .item-header {
    flex-wrap: wrap;
  }

  .item-meta {
    font-size: 0.75rem;
  }
}
